Skip to content

Latest commit

 

History

History
79 lines (63 loc) · 1.52 KB

CBCClientHowTo.md

File metadata and controls

79 lines (63 loc) · 1.52 KB

CBCClient User Guide

Create CBCClient instance

from requests_oauthlib import OAuth1
from connect_ext_ppr.client import CBCClient


# CBC Endpoint
endpoint = '******'
# CBC OAuth Key
client_id = '*****'
# CBC OAuth Key
client_secret = '*****'
# CBC Extension App ID
app_id = '*****'

client = CBCClient(
    endpoint=endpoint,
    auth=OAuth1(client_id, client_secret),
    app_id=app_id,
)

Fetching CBC resource

Syntax:

client['resource-identifier'].get()

Example - getting account with resource id 'afe386ae-1506-49b1-8c5d-b583b2eb6456':

account = client['afe386ae-1506-49b1-8c5d-b583b2eb6456'].get()

CBC Service Identification

Syntax:

client('aps-type')

Example of account service identification:

client('http://aps-standard.org/types/core/account')

Example of getting details of an account with id '1000017':

accounts = client('http://aps-standard.org/types/core/account').get(id=1000017)

Example of listing all accounts:

accounts = client('http://aps-standard.org/types/core/account').get()

Working with collections

Examples:

client('aps-type').collection.subs_collection.get()
client('aps-type').collection.subs_collection.action(
    name='action-name',
    payload=payload,
)

Working with resource

Examples:

client('aps-type').collection.subs_collection['identifier'].get()
client('aps-type').collection.subs_collection['identifier'].action(
    name='action-name',
    payload=payload,
)