Class: IllyanClient::Client
- Inherits:
-
Object
- Object
- IllyanClient::Client
- Defined in:
- lib/illyan_client/client.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #connection ⇒ Object
- #create_person(person) ⇒ Object
-
#initialize(base_url: nil, token: nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(base_url: nil, token: nil) ⇒ Client
8 9 10 11 |
# File 'lib/illyan_client/client.rb', line 8 def initialize(base_url: nil, token: nil) @base_url = base_url || IllyanClient.base_url @token = token || IllyanClient.token end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
6 7 8 |
# File 'lib/illyan_client/client.rb', line 6 def base_url @base_url end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/illyan_client/client.rb', line 6 def token @token end |
Instance Method Details
#connection ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/illyan_client/client.rb', line 13 def connection @connection ||= Faraday.new(url: base_url, headers: {'Accept' => 'application/json'}) do |conn| conn.request :basic_auth, token, '' conn.request :json conn.response :json conn.response :logger conn.adapter Faraday.default_adapter end end |
#create_person(person) ⇒ Object
25 26 27 |
# File 'lib/illyan_client/client.rb', line 25 def create_person(person) connection.post "/admin/people", { person: person.serializable_hash } end |