SkygearIO / skygear-SDK-iOS

Skygear SDK for iOS
https://skygear.io
Other
10 stars 28 forks source link

Update SDK API Grouping #104

Closed Steven-Chan closed 7 years ago

Steven-Chan commented 7 years ago

https://github.com/SkygearIO/features/pull/71

Grouping:

Container:

  state:
    url
    apiKey
    timeoutOptions
    auth(AuthContainer)
    relation(RelationContainer)
    db(DatabaseContainer)
    pubsub(PubsubContainer)
    push(PushContainer)
    chat(ChatContainer)
    analytics(AnalyticsContainer)

  api:
    config
    configApiKey
    lambda
    sendRequestObject
    makeRequest

AuthContainer:

  state:
    accessToken
    user(User)

  api:
    signupWithUsername
    signupWithEmail
    signupWithUsernameAndProfile
    signupWithEmailAndProfile
    signupAnonymously
    loginWithUsername
    loginWithEmail
    loginWithProvider
    logout
    changePassword
    forgotPassword
    // following api would be affected by https://github.com/SkygearIO/features/pull/68
    saveUser
    whoami
    getUsersByEmail
    getUsersByUsername
    discoverUserByEmails
    discoverUserByUsernames

RelationContainer:

  api:
    queryFriend
    queryFollower
    queryFollowing
    addRelation
    removeRelation

DatabaseContainer:

  state:
    public(PublicDatabase)
    private(PrivateDatabase)
    cacheResponse(Boolean)

  api:
    makeUploadAssetRequest

PublicDatabase:

  state:
    cacheStore

  api:
    setAdminRole
    setDefaultRole
    getDefaultACL
    setDefaultACL
    setRecordCreateAccess
    setRecordDefaultAccess
    getRecordByID
    save
    query
    del
    clearCache
    fetchSubscriptionWithID
    saveSubscription
    deleteSubscriptionWithID

PrivateDatabase:

  state:
    cacheStore

  api:
    getRecordByID
    save
    query
    del
    clearCache
    fetchSubscriptionWithID
    saveSubscription
    deleteSubscriptionWithID

PubsubContainer:

  state:
    channel
    internalChannel
    autoPubsub(Boolean)

  api:
    on
    off

PushContainer:

  state:
    deviceToken
    deviceID

  api:
    registerDevice
    unregisterDevice
    sendPushNotification

ChatContainer:

AnalyticsContainer:

Example:

// Call API
#import <SKYKit/SKYKit.h>

SKYContainer *container = [SKYContainer defaultContainer];
[container.auth loginWithEmail:@"email@example.com" password:@"secret" completion:nil];
[container.auth forgotPasswordWithEmail:@"email@example.com" completion:nil];
[container.pubsub subscribeTo:"channel" handler:nil];

SKYRecord *sampleItem = [SKYRecord recordWithRecordType:@"SampleItem"];
[container.db.public saveRecord:sampleItem completion:nil];
// Retrieve contexts
#import <SKYKit/SKYKit.h>

SKYContainer *container = [SKYContainer defaultContainer];
NSString *apiKey = [container apiKey];
NSString *currentAccessToken = [container.auth currentAccessToken];
NSDictionary *publicDBCache = [container.db.public cache];