Class: Trupanion::Client
- Inherits:
-
Object
- Object
- Trupanion::Client
- 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
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
readonly
Returns the value of attribute api_secret.
Instance Method Summary collapse
- #breeds ⇒ Object
- #delete(url) ⇒ Object
- #get(url, params: {}) ⇒ Object
-
#initialize(api_key:, api_secret:, sandbox: false) ⇒ Client
constructor
A new instance of Client.
- #policies ⇒ Object
- #post(url, body: {}) ⇒ Object
- #put(url, body: {}) ⇒ Object
- #quotes ⇒ Object
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_key ⇒ Object (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_secret ⇒ Object (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
#breeds ⇒ Object
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 |
#policies ⇒ Object
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 |