Class: Zipmark::Adapters::HTTPartyAdapter
- Inherits:
-
Object
- Object
- Zipmark::Adapters::HTTPartyAdapter
- Defined in:
- lib/zipmark/adapters/httparty_adapter.rb
Overview
Public: The HTTParty Adapter.
Important Note: PUT is broken in HTTParty when using Digest Auth
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#production ⇒ Object
Returns the value of attribute production.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #api_accept_mime ⇒ Object
- #api_endpoint ⇒ Object
- #delete(path) ⇒ Object
- #get(path) ⇒ Object
- #post(path, body) ⇒ Object
- #put(path, body) ⇒ Object
- #successful?(response) ⇒ Boolean
- #validation_error?(response) ⇒ Boolean
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
14 15 16 |
# File 'lib/zipmark/adapters/httparty_adapter.rb', line 14 def password @password end |
#production ⇒ Object
Returns the value of attribute production.
14 15 16 |
# File 'lib/zipmark/adapters/httparty_adapter.rb', line 14 def production @production end |
#username ⇒ Object
Returns the value of attribute username.
14 15 16 |
# File 'lib/zipmark/adapters/httparty_adapter.rb', line 14 def username @username end |
Instance Method Details
#api_accept_mime ⇒ Object
20 21 22 |
# File 'lib/zipmark/adapters/httparty_adapter.rb', line 20 def api_accept_mime "application/vnd.com.zipmark.#{API_VERSION}+json" end |
#api_endpoint ⇒ Object
16 17 18 |
# File 'lib/zipmark/adapters/httparty_adapter.rb', line 16 def api_endpoint production ? PRODUCTION_API_ENDPOINT : SANDBOX_API_ENDPOINT end |
#delete(path) ⇒ Object
36 37 38 |
# File 'lib/zipmark/adapters/httparty_adapter.rb', line 36 def delete(path) self.class.delete(path, ) end |
#get(path) ⇒ Object
24 25 26 |
# File 'lib/zipmark/adapters/httparty_adapter.rb', line 24 def get(path) self.class.get(path, ) end |
#post(path, body) ⇒ Object
28 29 30 |
# File 'lib/zipmark/adapters/httparty_adapter.rb', line 28 def post(path, body) self.class.post(path, .merge(:body => body.to_json)) end |
#put(path, body) ⇒ Object
32 33 34 |
# File 'lib/zipmark/adapters/httparty_adapter.rb', line 32 def put(path, body) self.class.put(path, .merge(:body => body.to_json)) end |
#successful?(response) ⇒ Boolean
40 41 42 |
# File 'lib/zipmark/adapters/httparty_adapter.rb', line 40 def successful?(response) response.code >= 200 && response.code < 300 end |
#validation_error?(response) ⇒ Boolean
44 45 46 |
# File 'lib/zipmark/adapters/httparty_adapter.rb', line 44 def validation_error?(response) response.code == 422 end |