Class: Cdek::Client
- Inherits:
-
Object
- Object
- Cdek::Client
- Defined in:
- lib/cdek/client.rb
Overview
Тонкий клиент-фасад над Cdek::Connection.
Реализует «сырые» вызовы CDEK API v2 без дополнительной семантики. Высокоуровневые ресурсы (Calculator, Orders, Locations, Offices, Webhooks) будут добавлены в следующей итерации.
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #delete(path, params: nil, headers: {}) ⇒ Object
- #get(path, params: nil, headers: {}) ⇒ Object
-
#initialize(configuration = Cdek.configuration) ⇒ Client
constructor
A new instance of Client.
- #patch(path, body: nil, headers: {}) ⇒ Object
- #post(path, body: nil, headers: {}) ⇒ Object
- #put(path, body: nil, headers: {}) ⇒ Object
- #reset_token! ⇒ Object
Constructor Details
#initialize(configuration = Cdek.configuration) ⇒ Client
Returns a new instance of Client.
12 13 14 15 |
# File 'lib/cdek/client.rb', line 12 def initialize(configuration = Cdek.configuration) @configuration = configuration @connection = Connection.new(configuration) end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
10 11 12 |
# File 'lib/cdek/client.rb', line 10 def configuration @configuration end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
10 11 12 |
# File 'lib/cdek/client.rb', line 10 def connection @connection end |
Instance Method Details
#delete(path, params: nil, headers: {}) ⇒ Object
33 34 35 |
# File 'lib/cdek/client.rb', line 33 def delete(path, params: nil, headers: {}) connection.authenticated_request(:delete, path, params: params, headers: headers) end |
#get(path, params: nil, headers: {}) ⇒ Object
17 18 19 |
# File 'lib/cdek/client.rb', line 17 def get(path, params: nil, headers: {}) connection.authenticated_request(:get, path, params: params, headers: headers) end |
#patch(path, body: nil, headers: {}) ⇒ Object
25 26 27 |
# File 'lib/cdek/client.rb', line 25 def patch(path, body: nil, headers: {}) connection.authenticated_request(:patch, path, body: body, headers: headers) end |
#post(path, body: nil, headers: {}) ⇒ Object
21 22 23 |
# File 'lib/cdek/client.rb', line 21 def post(path, body: nil, headers: {}) connection.authenticated_request(:post, path, body: body, headers: headers) end |
#put(path, body: nil, headers: {}) ⇒ Object
29 30 31 |
# File 'lib/cdek/client.rb', line 29 def put(path, body: nil, headers: {}) connection.authenticated_request(:put, path, body: body, headers: headers) end |
#reset_token! ⇒ Object
37 38 39 |
# File 'lib/cdek/client.rb', line 37 def reset_token! connection.reset_token! end |