Class: ShippyProAPI::Client
- Inherits:
-
Object
- Object
- ShippyProAPI::Client
- Defined in:
- lib/shippy_pro_api/client.rb
Constant Summary collapse
- BASE_URL =
'https://www.shippypro.com/api'
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(api_key:, adapter: Faraday.default_adapter) ⇒ Client
constructor
A new instance of Client.
- #shipment ⇒ Object
Constructor Details
#initialize(api_key:, adapter: Faraday.default_adapter) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/shippy_pro_api/client.rb', line 9 def initialize(api_key:, adapter: Faraday.default_adapter) @api_key = api_key @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
7 8 9 |
# File 'lib/shippy_pro_api/client.rb', line 7 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/shippy_pro_api/client.rb', line 7 def api_key @api_key end |
Instance Method Details
#connection ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/shippy_pro_api/client.rb', line 14 def connection @connection ||= Faraday.new do |conn| conn.url_prefix = BASE_URL conn.headers['Authorization'] = "Basic #{encoded_credentials}" conn.request :json conn.response :json, content_type: "application/json" conn.adapter adapter end end |
#shipment ⇒ Object
24 25 26 |
# File 'lib/shippy_pro_api/client.rb', line 24 def shipment ShipmentResource.new(self) end |