Skip to content

New interface #18

Description

@jasonkuhrt

The following sketches the core necessary actions and their types.

-- Devices Actions

devicesGet :: AccessToken -> Promise (List Device)

-- Device Actions

devicePost     :: AccessToken -> DeviceSpec -> Promise Device
deviceSettings :: AccessToken -> DeviceID -> SettingsSpec -> Promise Device
deviceGet      :: AccessToken -> DeviceID -> Promise Device
deviceDelete   :: AccessToken -> DeviceID -> Promise Device

-- Device Input Actions

deviceInputGet :: AccessToken -> DeviceID -> ReadSemantics -> Promise InputEvent

-- Device Output Actions

deviceOutputPost :: AccessToken -> DeviceID -> Promise ()

-- Relation Actions

relationPost         :: AccessToken -> RelationSpec -> Promise Relation
relationGet          :: AccessToken -> EdgeIdent -> Promise Relation
relationGetSubjects  :: AccessToken -> VertexID -> Promise (List Relation)
relationGetObservers :: AccessToken -> VertexID -> Promise (List Relation)
relationDelete       :: AccessToken -> EdgeIdent -> Promise Relation

Sugar for AccessToken

There should be an easy way for the user to get an API that has the first argument AccessToken applied. For example the following could return whole API with AccessToken partially applied to each action:

littleBitsCloud
  .withUser('83hs026fbn2pqw=27qbs91571k')
  // deviceSettings :: DeviceID -> SettingsSpec -> Promise Device
  // deviceGet      :: DeviceID -> Promise Device
  // etc.

Sugar for DeviceID

There should be an easy way for the user to get an API to work with a specific device wherein the second argument DeviceID is applied. For example:

littleBitsCloud
  .withUser('83hs026fbn2pqw=27qbs91571k')
  .withDevice('71d1hoa610')
  // deviceSettings :: SettingsSpec -> Promise Device
  // deviceGet      :: Promise Device
  // etc.

The returned API function names should have aliases that drop the device prefix given that it is redundant in this chaining context. So for example these two would be the same:

littleBitsCloud
  .withUser('83hs026fbn2pqw=27qbs91571k')
  .withDevice('71d1hoa610')
  .deviceSettings({ input_interval_ms: 50 })
  // ...
littleBitsCloud
  .withUser('83hs026fbn2pqw=27qbs91571k')
  .withDevice('71d1hoa610')
  .settings({ input_interval_ms: 50 })
  // ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions