Coder Social home page Coder Social logo

layer-python's Introduction

Layer Platform API Client

About

This library provides a simple python wrapper around the Layer Platform API for managing conversations, messages and announcements.

The project is currently in Alpha, so please report any bugs or missing features.

Installation

Using pip:

$ pip install LayerClient

Or, download the source code and run

$ python setup.py install

There is a tox configuration to make testing and linting easier - the following are supported:

$ tox                    # Runs py27-test (unit tests under python 2.7) by default
$ tox -e py3-test        # Runs tests under python3
$ tox -e py27-coverage   # Run test coverage report
$ tox -e lint            # Check for flake8 violations

Usage

The interface is close to that of the HTTP API itself. Here is an example of a sending a simple message:

from LayerClient import LayerClient

LAYER_APP_ID = 'your_app_uuid'
LAYER_APP_TOKEN = 'bearer_token_from_layer_console'

client = LayerClient.PlatformClient(
    LAYER_APP_ID,
    LAYER_APP_TOKEN,
)

sender = LayerClient.Sender(
    id='alice',
    name='Alice',
)

receiver = LayerClient.Sender(
    id='bob',
    name='Bob',
)

conversation = client.create_conversation(
    [
        sender.id,
        receiver.id,
    ],
    distinct=True,
    metadata={
        'background_color': '#3c3c3c',
        'title': 'A test conversaton',
    }
)

message_parts = [
    LayerClient.MessagePart(
        'Sure is nice to not talk about Crypto for a change!'
    ),
]

notification = LayerClient.PushNotification(
    'You got a message from Alice!'
)

message_resp = client.send_message(
    conversation,
    sender,
    message_parts,
    notification=notification,
)

layer-python's People

Contributors

bartoszhernas avatar rschlaikjer avatar dulacp avatar shriramk avatar bimusiek avatar billy-jana avatar chris-jana avatar mmcmahon-jana avatar vivek-graas avatar abdinoor-jana avatar craig-jana avatar

Watchers

 avatar

Forkers

hemantgurnani

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.