Class: Amazon::MWS::Response
- Inherits:
-
Object
- Object
- Amazon::MWS::Response
- Includes:
- ROXML
- Defined in:
- lib/amazon/mws/response.rb,
lib/amazon/mws/response/response.rb
Direct Known Subclasses
CancelFeedSubmissionsResponse, CancelFulfillmentOrderResponse, CancelReportRequestsResponse, CreateFulfillmentOrderResponse, FeedSubmission, FulFillmentOrderItem, FulfillmentAddress, FulfillmentOrder, FulfillmentShipment, FulfillmentShipmentItem, GetFeedSubmissionCountResponse, GetFeedSubmissionListByNextTokenResponse, GetFeedSubmissionListResponse, GetFeedSubmissionResultResponse, GetFeedSubmissionResultResponse::Header, GetFeedSubmissionResultResponse::Message, GetFeedSubmissionResultResponse::ProcessingSummary, GetFeedSubmissionResultResponse::Result, GetFulfillmentOrderResponse, GetMatchingProductForIdResponse, GetMatchingProductForIdResult, GetMatchingProductResponse, GetReportCountResponse, GetReportListResponse, GetReportRequestCountResponse, GetReportRequestListByNextTokenResponse, GetReportRequestListResponse, GetReportScheduleCountResponse, GetReportScheduleListByNextTokenResponse, GetReportScheduleListResponse, ListAllFulfillmentOrdersByNextTokenResponse, ListAllFulfillmentOrdersResponse, ManageReportScheduleResponse, Order, OrderItem, ProductRequest, PromotionId, ReportInfo, ReportRequest, ReportSchedule, RequestGetOrderResponse, RequestOrderItemsByNextTokenResponse, RequestOrderItemsResponse, RequestOrdersByNextTokenResponse, RequestOrdersResponse, RequestReportResponse, ResponseError, SubmitFeedResponse, UpdateReportAcknowledgementsResponse
Class Method Summary collapse
-
.format(response) ⇒ Object
This is the factoryish method that is called!, not new.
- .parse_xml(response) ⇒ Object
Instance Method Summary collapse
- #accessors ⇒ Object
-
#as_hash ⇒ Object
render a ROXML object as a normal hash, eliminating the @ and some unneeded admin fields.
Class Method Details
.format(response) ⇒ Object
This is the factoryish method that is called!, not new
9 10 11 12 13 14 15 |
# File 'lib/amazon/mws/response.rb', line 9 def self.format(response) if response.content_type =~ /xml/ || response.body =~ /<?xml/ parse_xml(response) else response.body end end |
.parse_xml(response) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/amazon/mws/response.rb', line 17 def self.parse_xml(response) if [Net::HTTPClientError, Net::HTTPServerError].any? {|error| response.is_a? error } return ResponseError.from_xml(response.body) else return self.from_xml(response.body) end end |
Instance Method Details
#accessors ⇒ Object
25 26 27 |
# File 'lib/amazon/mws/response.rb', line 25 def accessors roxml_references.map {|r| r.accessor} end |
#as_hash ⇒ Object
render a ROXML object as a normal hash, eliminating the @ and some unneeded admin fields
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/amazon/mws/response.rb', line 30 def as_hash obj_hash = {} self.instance_variables.each do |v| m = v.to_s.sub('@','') if m != 'roxml_references' && m!= 'promotion_ids' obj_hash[m.to_sym] = self.instance_variable_get(v) end end obj_hash end |