Class: AxiomusApi::Session
- Inherits:
-
Object
- Object
- AxiomusApi::Session
- Includes:
- Actions
- Defined in:
- lib/axiomus_api/session.rb
Constant Summary
Constants included from Actions
Instance Attribute Summary collapse
-
#test ⇒ Object
readonly
Returns the value of attribute test.
Instance Method Summary collapse
- #get_regions ⇒ Object
- #get_version ⇒ Object
-
#initialize(uid, ukey, test = true) ⇒ Session
constructor
A new instance of Session.
- #labels_link(orders) ⇒ Object
- #send_order_request(mode, order) ⇒ Object
- #status(okey) ⇒ Object
- #status_list(okeys) ⇒ Object
Methods included from Actions
Constructor Details
#initialize(uid, ukey, test = true) ⇒ Session
Returns a new instance of Session.
14 15 16 17 18 19 20 21 22 |
# File 'lib/axiomus_api/session.rb', line 14 def initialize(uid, ukey, test = true) @test = test @uid = uid @ukey = ukey if(block_given?) yield self end end |
Instance Attribute Details
#test ⇒ Object (readonly)
Returns the value of attribute test.
12 13 14 |
# File 'lib/axiomus_api/session.rb', line 12 def test @test end |
Instance Method Details
#get_regions ⇒ Object
34 35 36 37 38 39 |
# File 'lib/axiomus_api/session.rb', line 34 def get_regions() xml_request = create_request(:get_regions) xml_request.auth.ukey = @ukey response = send_request(xml_request) AxiomusApi::RegionsResponse.new (response.body) end |
#get_version ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/axiomus_api/session.rb', line 59 def get_version xml_request = create_request(:get_version) xml_request.auth = nil response = send_request(xml_request) version_response = AxiomusApi::VersionResponse.new(response.body) version_response.version end |
#labels_link(orders) ⇒ Object
86 87 88 |
# File 'lib/axiomus_api/session.rb', line 86 def labels_link(orders) "http://axiomus.ru/system/control/_call.php?mode=label&order=#{orders.join(',')}" end |
#send_order_request(mode, order) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/axiomus_api/session.rb', line 67 def send_order_request(mode, order) if(!order.valid?) error_msg = order.validation_errors.join('\n') logger.error(error_msg) raise AxiomusApi::Errors::ValidationError.new, order.validation_errors.join(error_msg) end xml_request = get_order_request(mode, order) response = send_request(xml_request) order_response = AxiomusApi::OrderResponse.new(response.body) if !order_response.success? log_response_error(order_response., xml_request.to_xml, response.body) raise AxiomusApi::Errors::RequestError.new(order_response.code), order_response. end order_response end |
#status(okey) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/axiomus_api/session.rb', line 41 def status(okey) xml_request = create_request(:status) xml_request.auth = nil xml_request.okey = okey response = send_request(xml_request) status_response = AxiomusApi::StatusResponse.new(response.body) status_response end |
#status_list(okeys) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/axiomus_api/session.rb', line 50 def status_list(okeys) xml_request = create_request(:status_list) xml_request.auth = nil xml_request.okeys = okeys response = send_request(xml_request) status_response = AxiomusApi::StatusListResponse.new(response.body) status_response end |