Class: Wdt::Client
- Inherits:
-
Object
- Object
- Wdt::Client
- Includes:
- Authentication, Shipments, Stocks, Trades
- Defined in:
- lib/wdt/client.rb,
lib/wdt/client/stocks.rb,
lib/wdt/client/trades.rb,
lib/wdt/client/shipments.rb
Defined Under Namespace
Modules: Shipments, Stocks, Trades
Constant Summary
Constants included from Authentication
Authentication::SEPARATOR1, Authentication::SEPARATOR2, Authentication::SEPARATOR3
Instance Method Summary collapse
- #config ⇒ Object
-
#delete(url, options = {}) ⇒ Object
Make a HTTP delete request.
-
#get(url, options = {}) ⇒ Object
Make a HTTP GET request.
-
#head(url, options = {}) ⇒ Object
Make a HTTP HEAD request.
-
#initialize(options = {}) ⇒ Client
constructor
Creates a new API.
-
#patch(url, options = {}) ⇒ Object
Make a HTTP PATCH request.
-
#post(url, options = {}) ⇒ Object
Make a HTTP POST request.
-
#put(url, options = {}) ⇒ Object
Make a HTTP PUT request.
-
#request(method, path, payload) ⇒ Object
Executes the request, checking if it was successfull.
Methods included from Shipments
#ack_shipments, #query_shipments
Methods included from Trades
Methods included from Authentication
#get_signature, #sign, #stringify_keys
Constructor Details
#initialize(options = {}) ⇒ Client
Creates a new API
17 18 19 20 21 22 |
# File 'lib/wdt/client.rb', line 17 def initialize(={}) = Wdt..merge() Configuration::VALID_OPTIONS_KEYS.each do |key| send("#{key}=", [key]) end end |
Instance Method Details
#config ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/wdt/client.rb', line 24 def config conf = {} Configuration::VALID_OPTIONS_KEYS.each do |key| conf[key] = send key end conf end |
#delete(url, options = {}) ⇒ Object
Make a HTTP delete request
43 44 45 |
# File 'lib/wdt/client.rb', line 43 def delete(url, = {}) request :delete, url, end |
#get(url, options = {}) ⇒ Object
Make a HTTP GET request
33 34 35 |
# File 'lib/wdt/client.rb', line 33 def get(url, = {}) request :get, url, end |
#head(url, options = {}) ⇒ Object
Make a HTTP HEAD request
53 54 55 |
# File 'lib/wdt/client.rb', line 53 def head(url, = {}) request :head, url, end |
#patch(url, options = {}) ⇒ Object
Make a HTTP PATCH request
58 59 60 |
# File 'lib/wdt/client.rb', line 58 def patch(url, = {}) request :patch, url, end |
#post(url, options = {}) ⇒ Object
Make a HTTP POST request
38 39 40 |
# File 'lib/wdt/client.rb', line 38 def post(url, = {}) request :post, url, end |
#put(url, options = {}) ⇒ Object
Make a HTTP PUT request
48 49 50 |
# File 'lib/wdt/client.rb', line 48 def put(url, = {}) request :put, url, end |
#request(method, path, payload) ⇒ Object
Executes the request, checking if it was successfull.
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/wdt/client.rb', line 63 def request(method, path, payload) payload = sign(payload) response = RestClient::Request.execute( :method => method, :url => endpoint + path, :payload => payload, :timeout => 10, :open_timeout => 10 ) response_hash = JSON.parse response Response.new(response_hash) end |