Class: Trupanion::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/trupanion/client.rb

Constant Summary collapse

API_BASE =
"https://api.trupanion.com".freeze
SANDBOX_API_BASE =
"https://sandbox.api.trupanion.com".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, api_secret:, sandbox: false) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
# File 'lib/trupanion/client.rb', line 14

def initialize(api_key:, api_secret:, sandbox: false)
  @api_key = api_key
  @api_secret = api_secret
  @sandbox = sandbox
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



12
13
14
# File 'lib/trupanion/client.rb', line 12

def api_key
  @api_key
end

#api_secretObject (readonly)

Returns the value of attribute api_secret.



12
13
14
# File 'lib/trupanion/client.rb', line 12

def api_secret
  @api_secret
end

Instance Method Details

#breedsObject



40
# File 'lib/trupanion/client.rb', line 40

def breeds; API::Breeds.new(self); end

#delete(url) ⇒ Object



32
33
34
# File 'lib/trupanion/client.rb', line 32

def delete(url)
  conn.delete(url)
end

#get(url, params: {}) ⇒ Object



20
21
22
23
24
# File 'lib/trupanion/client.rb', line 20

def get(url, params: {})
  conn.get(url, params) do |req|
    req.headers = AuthorizationHeaders.new(self, req).call
  end
end

#policiesObject



44
# File 'lib/trupanion/client.rb', line 44

def policies; API::Policies.new(self); end

#post(url, body: {}) ⇒ Object



26
27
28
29
30
# File 'lib/trupanion/client.rb', line 26

def post(url, body: {})
  conn.post(url, body) do |req|
    req.headers = AuthorizationHeaders.new(self, req).call
  end
end

#put(url, body: {}) ⇒ Object



36
37
38
# File 'lib/trupanion/client.rb', line 36

def put(url, body: {})
  conn.put(url, body)
end

#quotesObject



42
# File 'lib/trupanion/client.rb', line 42

def quotes; API::Quotes.new(self); end