Module: Particle::Client::OAuthClients

Included in:
Particle::Client
Defined in:
lib/particle/client/oauth_clients.rb

Overview

Client methods for the Particle OAuth client API

Instance Method Summary collapse

Instance Method Details

#create_oauth_client(attributes) ⇒ OAuthClient

Create a Particle OAuth client

Parameters:

  • options (Hash)

    Options to configure the client

Returns:

  • (OAuthClient)

    An OAuth client object to interact with



37
38
39
40
# File 'lib/particle/client/oauth_clients.rb', line 37

def create_oauth_client(attributes)
  result = post(OAuthClient.create_path, attributes)
  oauth_client(result[:client])
end

#oauth_client(target) ⇒ OAuthClient

Create a domain model for a Particle OAuth client

Parameters:

Returns:

  • (OAuthClient)

    A OAuth client object to interact with



15
16
17
18
19
20
21
# File 'lib/particle/client/oauth_clients.rb', line 15

def oauth_client(target)
  if target.is_a? OAuthClient
    target
  else
    OAuthClient.new(self, target)
  end
end

#oauth_clientsArray<OAuthClient>

List all Particle OAuth clients on the account

Returns:

  • (Array<OAuthClient>)

    List of Particle OAuth clients to interact with



26
27
28
29
30
31
# File 'lib/particle/client/oauth_clients.rb', line 26

def oauth_clients
  result = get(OAuthClient.list_path)
  result[:clients].map do |attributes|
    oauth_client(attributes)
  end
end

#remove_oauth_client(target) ⇒ boolean

Remove a Particle OAuth client

Parameters:

Returns:

  • (boolean)

    true for success



46
47
48
49
# File 'lib/particle/client/oauth_clients.rb', line 46

def remove_oauth_client(target)
  delete(oauth_client(target).path)
  true
end