Class: PayrollHero::Api::Client
- Inherits:
-
Object
- Object
- PayrollHero::Api::Client
- Defined in:
- lib/payroll_hero/api/client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #delete(path, params = {}) ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(token, base_url) ⇒ Client
constructor
A new instance of Client.
- #post(path, params) ⇒ Object
Constructor Details
#initialize(token, base_url) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/payroll_hero/api/client.rb', line 11 def initialize(token, base_url) headers = { 'User-Agent' => user_agent_string, } params = { token: token, } @client = Faraday.new(url: base_url) do |faraday| faraday.request :url_encoded faraday.response :logger if PayrollHero::Api.debug faraday.use FaradayMiddleware::Mashify faraday.response :json, content_type: /\bjson$/ faraday.headers.merge! headers faraday.params.merge! params faraday.adapter Faraday.default_adapter end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/payroll_hero/api/client.rb', line 9 def client @client end |
Instance Method Details
#delete(path, params = {}) ⇒ Object
40 41 42 |
# File 'lib/payroll_hero/api/client.rb', line 40 def delete(path, params = {}) do_request(:delete, path, params) end |
#get(path, params = {}) ⇒ Object
32 33 34 |
# File 'lib/payroll_hero/api/client.rb', line 32 def get(path, params = {}) do_request(:get, path, params) end |
#post(path, params) ⇒ Object
36 37 38 |
# File 'lib/payroll_hero/api/client.rb', line 36 def post(path, params) do_request(:post, path, params) end |