Class: Apress::Moysklad::Api::Client
- Inherits:
-
Object
- Object
- Apress::Moysklad::Api::Client
- Defined in:
- lib/apress/moysklad/api/client.rb
Overview
Клиент для взаимодействия с API МойСклад
Constant Summary collapse
- API_URL =
'https://online.moysklad.ru/api/remap'.freeze
- API_VERSION =
'1.1'.freeze
- TIMEOUT =
seconds
60
Instance Attribute Summary collapse
-
#login ⇒ Object
readonly
Returns the value of attribute login.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
Instance Method Summary collapse
- #get(entity, params = {}) ⇒ Object
-
#initialize(login, password) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(login, password) ⇒ Client
25 26 27 28 |
# File 'lib/apress/moysklad/api/client.rb', line 25 def initialize(login, password) @login = login @password = password end |
Instance Attribute Details
#login ⇒ Object (readonly)
Returns the value of attribute login.
23 24 25 |
# File 'lib/apress/moysklad/api/client.rb', line 23 def login @login end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
23 24 25 |
# File 'lib/apress/moysklad/api/client.rb', line 23 def password @password end |
Instance Method Details
#get(entity, params = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/apress/moysklad/api/client.rb', line 30 def get(entity, params = {}) uri = api_uri(entity) uri.query = URI.encode_www_form(params) unless params.empty? req = Net::HTTP::Get.new(uri) req.basic_auth login, password res = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(req) end parse_response(res) end |