Class: BactracsService
- Inherits:
-
Object
- Object
- BactracsService
- Defined in:
- lib/bactracs_service.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize ⇒ BactracsService
constructor
A new instance of BactracsService.
- #rma_was_synced?(shipment) ⇒ Boolean
Constructor Details
#initialize ⇒ BactracsService
Returns a new instance of BactracsService.
9 10 11 12 13 14 15 |
# File 'lib/bactracs_service.rb', line 9 def initialize @username = SolidusBactracs.configuration.authentication_username @password = SolidusBactracs.configuration.authentication_password @runner = SolidusBactracs::Api::RequestRunner.new # Authenticate account authenticate! end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
7 8 9 |
# File 'lib/bactracs_service.rb', line 7 def token @token end |
Instance Method Details
#rma_was_synced?(shipment) ⇒ Boolean
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bactracs_service.rb', line 17 def rma_was_synced?(shipment) if @token.present? response = @runner.call( method: :post, path: "/webservices/rma/rmaservice.asmx?op=Read", params: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soap:Body> <Read xmlns=\"http://bactracs.andlor.com/rmaservice\">\n <sGuid>#{@token}</sGuid>\n <sRMANumber>#{shipment.number}</sRMANumber>\n </Read>\n </soap:Body>\n </soap:Envelope>" ) if response return response.dig("Envelope", "Body", "ReadResponse", "ReadResult", "oRMA").present? rescue false end end return false rescue => e Rails.logger.error({ message: e..to_s, file: "bactracs_service.rb" }) return false end |