Class: Plangrade::Client

Inherits:
Object
  • Object
show all
Includes:
Api::Company, Api::Participant, Api::User, Configurable
Defined in:
lib/plangrade/client.rb

Constant Summary

Constants included from Configurable

Plangrade::Configurable::ENDPOINT, Plangrade::Configurable::HTTP_ADAPTER

Instance Attribute Summary collapse

Attributes included from Configurable

#http_adapter

Instance Method Summary collapse

Methods included from Api::Participant

#all_participants, #create_participant, #delete_participant, #get_participant, #update_participant

Methods included from Api::Company

#all_companies, #create_company, #delete_company, #get_company, #update_company

Methods included from Api::User

#create_user, #current_user, #delete_user, #update_user

Methods included from Configurable

#configure, default_options, #disable_logging, #enable_logging, keys, #options, #reset!, #with_logging

Constructor Details

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/plangrade/client.rb', line 17

def initialize(opts={})
  Plangrade::Configurable.keys.each do |key|
    case key
    when :headers, :connection_options
      value = Plangrade.instance_variable_get(:"@#{key}").merge(opts.fetch(key, {}))
    else
      value = opts.fetch(key, Plangrade.instance_variable_get(:"@#{key}"))
    end
    instance_variable_set(:"@#{key}", value)
  end
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



15
16
17
# File 'lib/plangrade/client.rb', line 15

def access_token
  @access_token
end

#client_idObject

Returns the value of attribute client_id.



15
16
17
# File 'lib/plangrade/client.rb', line 15

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



15
16
17
# File 'lib/plangrade/client.rb', line 15

def client_secret
  @client_secret
end

#connection_optionsObject (readonly)

Returns the value of attribute connection_options.



13
14
15
# File 'lib/plangrade/client.rb', line 13

def connection_options
  @connection_options
end

#default_headersObject (readonly)

Returns the value of attribute default_headers.



13
14
15
# File 'lib/plangrade/client.rb', line 13

def default_headers
  @default_headers
end

#site_urlObject (readonly)

Returns the value of attribute site_url.



13
14
15
# File 'lib/plangrade/client.rb', line 13

def site_url
  @site_url
end

Instance Method Details

#delete(path, params = {}) ⇒ Object

makes a DELETE request



45
46
47
# File 'lib/plangrade/client.rb', line 45

def delete(path, params={})
  request(:delete, path, params)
end

#get(path, params = {}) ⇒ Object

makes a GET request



30
31
32
# File 'lib/plangrade/client.rb', line 30

def get(path, params={})
  request(:get, path, params)
end

#post(path, params = {}) ⇒ Object

makes a POST request



40
41
42
# File 'lib/plangrade/client.rb', line 40

def post(path, params={})
  request(:post, path, params)
end

#put(path, params = {}) ⇒ Object

makes a PUT request



35
36
37
# File 'lib/plangrade/client.rb', line 35

def put(path, params={})
  request(:put, path, params)
end