Class: Etna::Client
- Inherits:
-
Object
- Object
- Etna::Client
- Defined in:
- lib/etna/client.rb
Instance Attribute Summary collapse
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Instance Method Summary collapse
- #delete(endpoint, params = {}, &block) ⇒ Object
- #get(endpoint, params = {}, &block) ⇒ Object
-
#initialize(host, token, routes_available: true, persistent: true, ignore_ssl: false) ⇒ Client
constructor
A new instance of Client.
- #multipart_post(endpoint, content, &block) ⇒ Object
- #options(endpoint, params = {}, &block) ⇒ Object
- #post(endpoint, params = {}, &block) ⇒ Object
- #route_path(route, params) ⇒ Object
Constructor Details
#initialize(host, token, routes_available: true, persistent: true, ignore_ssl: false) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/etna/client.rb', line 8 def initialize(host, token, routes_available: true, persistent: true, ignore_ssl: false) @host = host.sub(%r!/$!, '') @token = token @persistent = persistent @ignore_ssl = ignore_ssl if routes_available set_routes define_route_helpers end end |
Instance Attribute Details
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
20 21 22 |
# File 'lib/etna/client.rb', line 20 def routes @routes end |
Instance Method Details
#delete(endpoint, params = {}, &block) ⇒ Object
45 46 47 |
# File 'lib/etna/client.rb', line 45 def delete(endpoint, params = {}, &block) body_request(Net::HTTP::Delete, endpoint, params, &block) end |
#get(endpoint, params = {}, &block) ⇒ Object
37 38 39 |
# File 'lib/etna/client.rb', line 37 def get(endpoint, params = {}, &block) query_request(Net::HTTP::Get, endpoint, params, &block) end |
#multipart_post(endpoint, content, &block) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/etna/client.rb', line 26 def multipart_post(endpoint, content, &block) uri = request_uri(endpoint) multipart = Net::HTTP::Post::Multipart.new uri.request_uri, content multipart.add_field('Authorization', "Etna #{@token}") request(uri, multipart, &block) end |
#options(endpoint, params = {}, &block) ⇒ Object
41 42 43 |
# File 'lib/etna/client.rb', line 41 def (endpoint, params = {}, &block) query_request(Net::HTTP::Options, endpoint, params, &block) end |
#post(endpoint, params = {}, &block) ⇒ Object
33 34 35 |
# File 'lib/etna/client.rb', line 33 def post(endpoint, params = {}, &block) body_request(Net::HTTP::Post, endpoint, params, &block) end |