I'm new to Rails (but not new to web development in general). I'm using the mws-connect gem (https://github.com/devmode/mws) to connect to Amazon Marketplace Web Service. I'm trying to cancel an order, and according to the Amazon MWS API docs, the following xml code is what needs to be sent (as far as I can tell) :
<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier> M_IDENTIFIER</MerchantIdentifier>
</Header>
<MessageType>
OrderAcknowledgment
</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderAcknowledgement>
<AmazonOrderID>050-1234567-1234567</AmazonOrderID>
<StatusCode>Failure</StatusCode>
<CancelReason>Reason for cancellation</CancelReason>
</OrderAcknowledgment>
</Message>
</AmazonEnvelope>
The gem documentation isn't clear on how to do this since the examples are all for how to add or update a product listing, which I tested and works just fine. I've tried about every way I can think of to just build the "feed" request manually to submit it and use the rest of the class to handle the submission stuff since I know that works. The current example of the code that I have in a SalesOrder class is:
def self.cancel_amazon_order(amazon_order_id, cancel_reason)
mws = Mws.connect(
merchant: 'merchant_id',
access: 'access_key',
secret: 'secret'
)
cancel_feed = Mws::Feed.new 'merchant_id', :order_acknowledgement do
@messages << {
MessageID: '1',
OrderAcknowledgement: {
AmazonOrderID: amazon_order_id,
StatusCode: 'Failure',
CancelReason: cancel_reason
}
}
end
end
This code doesn't throw any errors, but when I try to do cancel_feed.to_xml
(what I can see is the next step towards submitting the feed), I get an error saying
ArgumentError: Namespace indent has not been defined
Are there any rails pros out there that might have an idea how to make this gem work, either the to_xml method, or better yet how to get the cancel itself through? I feel like I'm not too far off. I'm coming from a PHP background, so my thought process on this is probably off a bit. I've loved Rails so far, but I'm pulling my hair out on this one, any help is appreciated!