Class: MasonHubAPI::Client
- Inherits:
-
Object
- Object
- MasonHubAPI::Client
- Defined in:
- lib/mason_hub_api/client.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#bearer_token ⇒ Object
readonly
Returns the value of attribute bearer_token.
-
#sandbox ⇒ Object
readonly
Returns the value of attribute sandbox.
-
#url_slug ⇒ Object
readonly
Returns the value of attribute url_slug.
Instance Method Summary collapse
- #callback ⇒ Object
- #connection ⇒ Object
-
#initialize(url_slug:, base_path: "v1", bearer_token:, adapter: Faraday.default_adapter, sandbox: false) ⇒ Client
constructor
A new instance of Client.
- #return ⇒ Object
Constructor Details
#initialize(url_slug:, base_path: "v1", bearer_token:, adapter: Faraday.default_adapter, sandbox: false) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 |
# File 'lib/mason_hub_api/client.rb', line 7 def initialize(url_slug:, base_path: "v1", bearer_token:, adapter: Faraday.default_adapter, sandbox: false) @url_slug = url_slug @base_path = base_path @bearer_token = bearer_token @adapter = adapter @sandbox = sandbox end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/mason_hub_api/client.rb', line 5 def adapter @adapter end |
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
5 6 7 |
# File 'lib/mason_hub_api/client.rb', line 5 def base_path @base_path end |
#bearer_token ⇒ Object (readonly)
Returns the value of attribute bearer_token.
5 6 7 |
# File 'lib/mason_hub_api/client.rb', line 5 def bearer_token @bearer_token end |
#sandbox ⇒ Object (readonly)
Returns the value of attribute sandbox.
5 6 7 |
# File 'lib/mason_hub_api/client.rb', line 5 def sandbox @sandbox end |
#url_slug ⇒ Object (readonly)
Returns the value of attribute url_slug.
5 6 7 |
# File 'lib/mason_hub_api/client.rb', line 5 def url_slug @url_slug end |
Instance Method Details
#callback ⇒ Object
26 27 28 |
# File 'lib/mason_hub_api/client.rb', line 26 def callback @callbacks ||= CallbackResource.new(self) end |
#connection ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mason_hub_api/client.rb', line 15 def connection @connection ||= Faraday.new do |conn| conn.url_prefix = url_prefix conn.headers['Authorization'] = "Bearer #{bearer_token}" conn.headers['Content-Type'] = "application/json" conn.request :json conn.response :json, content_type: "application/json" conn.adapter adapter end end |
#return ⇒ Object
30 31 32 |
# File 'lib/mason_hub_api/client.rb', line 30 def return @returns ||= ReturnResource.new(self) end |