Class: MagicWrite::Client

Inherits:
Object
  • Object
show all
Includes:
HTTP
Defined in:
lib/magicwrite/client.rb

Constant Summary collapse

CONFIG_KEYS =
%i[
  access_token
  uri_base
  request_timeout
  extra_headers
].freeze

Instance Method Summary collapse

Methods included from HTTP

#delete, #get, #json_post, #json_put, #multipart_post

Constructor Details

#initialize(config = {}) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
# File 'lib/magicwrite/client.rb', line 13

def initialize(config = {})
  CONFIG_KEYS.each do |key|
    instance_variable_set("@#{key}", config[key] || MagicWrite.configuration.send(key))
  end
end

Instance Method Details

#agentsObject



19
20
21
# File 'lib/magicwrite/client.rb', line 19

def agents
  @agents ||= MagicWrite::Agents.new(client: self)
end

#companiesObject



23
24
25
# File 'lib/magicwrite/client.rb', line 23

def companies
  @companies ||= MagicWrite::Companies.new(client: self)
end

#completionsObject



27
28
29
# File 'lib/magicwrite/client.rb', line 27

def completions
  @completions ||= MagicWrite::Completions.new(client: self)
end

#ingestionsObject



31
32
33
# File 'lib/magicwrite/client.rb', line 31

def ingestions
  @ingestions ||= MagicWrite::Ingestions.new(client: self)
end

#membershipsObject



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

def memberships
  @memberships ||= MagicWrite::Memberships.new(client: self)
end

#sessionObject



39
40
41
# File 'lib/magicwrite/client.rb', line 39

def session
  get(path: '/session')
end