예제 #1
0
class Vms(Api):

    path = 'vms.do'

    send = bind_api_endpoint(method='POST',
                             path=path,
                             mapping=(SendResult, ResultCollection),
                             accept_parameters=accept_parameters + ['to'],
                             force_parameters=response_format_param,
                             exception_class=SendException,
                             parameters_transformer=parameters_transformer)

    send_to_group = bind_api_endpoint(
        method='POST',
        path=path,
        mapping=(SendResult, ResultCollection),
        accept_parameters=accept_parameters + ['group'],
        force_parameters=response_format_param,
        exception_class=SendException,
        parameters_transformer=parameters_transformer)

    remove_scheduled = bind_api_endpoint(
        method='GET',
        path=path,
        mapping=(RemoveMessageResult, ResultCollection),
        accept_parameters=['id'],
        force_parameters=response_format_param,
        exception_class=EndpointException)
예제 #2
0
class Sender(Api):

    path = 'sender.do'

    add = bind_api_endpoint(
        method='GET',
        path=path,
        mapping=SenderNameSuccessResult,
        accept_parameters=['name'],
        force_parameters=response_format_param,
        exception_class=EndpointException,
        parameters_transformer=parameters_transformer('add')
    )

    check = bind_api_endpoint(
        method='GET',
        path=path,
        mapping=SenderNameResult,
        accept_parameters=['name'],
        force_parameters=response_format_param,
        exception_class=EndpointException,
        parameters_transformer=parameters_transformer('status')
    )

    remove = bind_api_endpoint(
        method='GET',
        path=path,
        mapping=SenderNameSuccessResult,
        accept_parameters=['name'],
        force_parameters=response_format_param,
        exception_class=EndpointException,
        parameters_transformer=parameters_transformer('delete')
    )

    list = bind_api_endpoint(
        method='GET',
        path=path,
        mapping=(SenderNameResult, ResultCollection),
        force_parameters=update_dict(response_format_param, {'list': True}),
        exception_class=EndpointException
    )

    default = bind_api_endpoint(
        method='GET',
        path=path,
        mapping=SenderNameSuccessResult,
        accept_parameters=['name'],
        force_parameters=response_format_param,
        exception_class=EndpointException,
        parameters_transformer=parameters_transformer('default')
    )
예제 #3
0
class Account(Api):

    path = 'user.do'

    balance = bind_api_endpoint(method='GET',
                                path=path,
                                mapping=AccountBalanceResult,
                                force_parameters=update_dict(
                                    response_format_param, {
                                        'credits': 1,
                                        'details': 1
                                    }),
                                exception_class=EndpointException)

    user = bind_api_endpoint(method='GET',
                             path=path,
                             mapping=UserResult,
                             accept_parameters=['name'],
                             force_parameters=response_format_param,
                             exception_class=EndpointException,
                             parameters_transformer=parameters_transformer(
                                 {'name': 'get_user'}))

    create_user = bind_api_endpoint(
        method='GET',
        path=path,
        mapping=UserResult,
        accept_parameters=accept_parameters,
        force_parameters=response_format_param,
        exception_class=EndpointException,
        parameters_transformer=parameters_transformer({'name': 'add_user'}))

    update_user = bind_api_endpoint(
        method='GET',
        path=path,
        mapping=UserResult,
        accept_parameters=accept_parameters,
        force_parameters=response_format_param,
        exception_class=EndpointException,
        parameters_transformer=parameters_transformer({'name': 'set_user'}))

    list_users = bind_api_endpoint(method='GET',
                                   path=path,
                                   mapping=(UserResult, ResultCollection),
                                   force_parameters=update_dict(
                                       response_format_param, {'list': 1}),
                                   exception_class=EndpointException)
예제 #4
0
class Push(Api):

    send = bind_api_endpoint(
        method='POST',
        path='push',
        mapping=PushShipment,
        exception_class=EndpointException,
        accept_parameters=accept_parameters,
        parameters_transformer=parameters_transformer
    )
예제 #5
0
class Hlr(Api):

    path = 'hlr.do'

    check_number = bind_api_endpoint(
        method='GET',
        path=path,
        mapping=HlrResult,
        accept_parameters=['number', 'idx'],
        force_parameters=response_format_param,
        exception_class=EndpointException,
        parameters_transformer=parameters_transformer
    )
예제 #6
0
class Blacklist(Api):

    path = 'blacklist/phone_numbers'

    list_phone_numbers = bind_api_endpoint(method='GET',
                                           path=path,
                                           mapping=(BlacklistPhoneNumber,
                                                    ModelCollection),
                                           accept_parameters=list_params,
                                           exception_class=EndpointException)

    add_phone_number = bind_api_endpoint(method='POST',
                                         path=path,
                                         mapping=BlacklistPhoneNumber,
                                         accept_parameters=accept_parameters,
                                         exception_class=EndpointException)

    delete_phone_number = bind_api_endpoint(method='DELETE',
                                            path="%s/{id}" % path,
                                            accept_parameters=['id'],
                                            exception_class=EndpointException)

    delete_all_phone_numbers = bind_api_endpoint(
        method='DELETE', path=path, exception_class=EndpointException)
예제 #7
0
class ShortUrl(Api):

    get_clicks = bind_api_endpoint(
        method='GET',
        path='short_url/clicks',
        mapping=(ShortUrlClick, ModelCollection),
        exception_class=EndpointException,
        accept_parameters=clicks_accept_parameters,
        parameters_transformer=clicks_parameters_transformer)

    get_clicks_by_mobile_device = bind_api_endpoint(
        method='GET',
        path='short_url/clicks_by_mobile_device',
        mapping=(ShortUrlClickByMobileDevice, ModelCollection),
        exception_class=EndpointException,
        accept_parameters=clicks_accept_parameters,
        parameters_transformer=clicks_parameters_transformer)

    list_short_urls = bind_api_endpoint(method='GET',
                                        path='short_url/links',
                                        mapping=(ShortUrlModel,
                                                 ModelCollection),
                                        exception_class=EndpointException)

    create_short_url = bind_api_endpoint(
        method='POST',
        path='short_url/links',
        mapping=ShortUrlModel,
        exception_class=EndpointException,
        accept_parameters=short_url_parameters,
        parameters_transformer=parameters_transformer)

    get_short_url = bind_api_endpoint(method='GET',
                                      path='short_url/links/{id}',
                                      mapping=ShortUrlModel,
                                      exception_class=EndpointException,
                                      accept_parameters=['id'])

    update_short_url = bind_api_endpoint(method='PUT',
                                         path='short_url/links/{id}',
                                         mapping=ShortUrlModel,
                                         exception_class=EndpointException,
                                         accept_parameters=['id'])

    remove_short_url = bind_api_endpoint(method='DELETE',
                                         path='short_url/links/{id}',
                                         exception_class=EndpointException,
                                         accept_parameters=['id'])
예제 #8
0
class Contacts(Api):

    list_contacts = bind_api_endpoint(method='GET',
                                      path='contacts',
                                      mapping=(ContactModel, ModelCollection),
                                      exception_class=ContactsException,
                                      accept_parameters=contact_params +
                                      list_params + ['q'])

    get_contact = bind_api_endpoint(method='GET',
                                    path='contacts/{contact_id}',
                                    mapping=ContactModel,
                                    exception_class=ContactsException,
                                    accept_parameters=['contact_id'])

    update_contact = bind_api_endpoint(method='PUT',
                                       path='contacts/{contact_id}',
                                       mapping=ContactModel,
                                       exception_class=ContactsException,
                                       accept_parameters=contact_params +
                                       ['contact_id'])

    create_contact = bind_api_endpoint(method='POST',
                                       path='contacts',
                                       mapping=ContactModel,
                                       exception_class=ContactsException,
                                       accept_parameters=contact_params)

    delete_contact = bind_api_endpoint(method='DELETE',
                                       path='contacts/{contact_id}',
                                       exception_class=ContactsException,
                                       accept_parameters=['contact_id'])

    list_contact_groups = bind_api_endpoint(
        method='GET',
        path='contacts/{contact_id}/groups',
        mapping=(GroupModel, ModelCollection),
        exception_class=ContactsException,
        accept_parameters=['contact_id', 'group_id'])

    bind_contact_to_group = bind_api_endpoint(
        method='POST',
        path='contacts/{contact_id}/groups/{group_id}',
        exception_class=ContactsException,
        accept_parameters=['contact_id', 'group_id'])

    list_groups = bind_api_endpoint(
        method='GET',
        path='contacts/groups',
        mapping=(GroupModel, ModelCollection),
        accept_parameters=['group_id', 'name'],
        exception_class=ContactsException,
        force_parameters={'with': 'contacts_count'})

    create_group = bind_api_endpoint(
        method='POST',
        path='contacts/groups',
        mapping=GroupModel,
        exception_class=ContactsException,
        accept_parameters=['name', 'description', 'idx'])

    delete_group = bind_api_endpoint(method='DELETE',
                                     path='contacts/groups/{group_id}',
                                     exception_class=ContactsException,
                                     accept_parameters=['group_id'])

    get_group = bind_api_endpoint(method='GET',
                                  path='contacts/groups/{group_id}',
                                  mapping=GroupModel,
                                  accept_parameters=['group_id'],
                                  exception_class=ContactsException,
                                  force_parameters={'with': 'contacts_count'})

    update_group = bind_api_endpoint(
        method='PUT',
        path='contacts/groups/{group_id}',
        mapping=GroupModel,
        exception_class=ContactsException,
        accept_parameters=['group_id', 'name', 'description', 'idx'])

    list_group_permissions = bind_api_endpoint(
        method='GET',
        path='contacts/groups/{group_id}/permissions',
        mapping=GroupPermissionModel,
        exception_class=ContactsException,
        accept_parameters=['group_id'])

    create_group_permission = bind_api_endpoint(
        method='POST',
        path='contacts/groups/{group_id}/permissions',
        mapping=GroupPermissionModel,
        exception_class=ContactsException,
        accept_parameters=['group_id', 'username', 'read', 'write', 'send'])

    list_user_group_permissions = bind_api_endpoint(
        method='GET',
        path='contacts/groups/{group_id}/permissions/{username}',
        mapping=(GroupPermissionModel, ModelCollection),
        exception_class=ContactsException,
        accept_parameters=['group_id', 'username'])

    delete_user_group_permission = bind_api_endpoint(
        method='DELETE',
        path='contacts/groups/{group_id}/permissions/{username}',
        exception_class=ContactsException,
        accept_parameters=['group_id', 'username'])

    update_user_group_permission = bind_api_endpoint(
        method='PUT',
        path='contacts/groups/{group_id}/permissions/{username}',
        mapping=GroupPermissionModel,
        exception_class=ContactsException,
        accept_parameters=['group_id', 'username', 'read', 'write', 'send'])

    unpin_contact_from_group = bind_api_endpoint(
        method='DELETE',
        path='contacts/groups/{group_id}/members/{contact_id}',
        exception_class=ContactsException,
        accept_parameters=['group_id', 'contact_id'])

    contact_is_in_group = bind_api_endpoint(
        method='GET',
        path='contacts/groups/{group_id}/members/{contact_id}',
        mapping=ContactModel,
        exception_class=ContactsException,
        accept_parameters=['group_id', 'contact_id'])

    pin_contact_to_group = bind_api_endpoint(
        method='PUT',
        path='contacts/groups/{group_id}/members/{contact_id}',
        mapping=ContactModel,
        exception_class=ContactsException,
        accept_parameters=['group_id', 'contact_id'])

    list_custom_fields = bind_api_endpoint(method='GET',
                                           mapping=(CustomFieldModel,
                                                    ModelCollection),
                                           exception_class=ContactsException,
                                           path='contacts/fields')

    create_custom_field = bind_api_endpoint(method='POST',
                                            path='contacts/fields',
                                            mapping=CustomFieldModel,
                                            exception_class=ContactsException,
                                            accept_parameters=['name', 'type'])

    delete_custom_field = bind_api_endpoint(method='DELETE',
                                            path='contacts/fields',
                                            exception_class=ContactsException,
                                            accept_parameters=['field_id'])

    update_custom_field = bind_api_endpoint(method='PUT',
                                            path='contacts/fields',
                                            mapping=CustomFieldModel,
                                            exception_class=ContactsException,
                                            accept_parameters=['name', 'type'])

    unpin_contact_from_group_by_query = bind_api_endpoint(
        method='DELETE',
        path='contacts/groups/{group_id}/members',
        exception_class=ContactsException,
        accept_parameters=contact_params[:-1] + ['group_id', 'q'])

    count_contacts_in_trash = bind_api_endpoint(
        method='HEAD',
        path='contacts/trash',
        mapping=HeaderDirectResult('X-Result-Count'),
        exception_class=ContactsException)

    restore_contacts_in_trash = bind_api_endpoint(
        method='PUT', path='contacts/trash', exception_class=ContactsException)

    clean_trash = bind_api_endpoint(method='DELETE',
                                    path='contacts/trash',
                                    exception_class=ContactsException)