create inboundshipment using peddler in rails - ruby-on-rails

I tried to create InboundShipment.
client.create_inbound_shipment(id, inbound_shipment_header, inbound_shipment_items)
id is shipplan id created by Shipplan.
inbound_shipment_header = {:shipment_name=>"kum_03_01_2019_AVP1", :ship_from_address=>{:name=>"xxxx", :address_line1=>"xxxx", :address_line2=>"", :city=>"xxxx", :state_or_province_code=>"XX", :postal_code=>"xxxx", :country_code=>"xxxx"}, :destination_fulfillment_center_id=>"AVP1", :label_prep_preference=>"SELLER_LABEL", :are_cases_required=>false, :shipment_status=>"WORKING", :intended_box_contents_source=>"2D_BARCODE"}
inbound_shipment_items = [{:seller_sku=>"SKU", :quantity=>25, :prep_details=>[{:prep_instruction=>"Labeling", :prep_owner=>"SELLER"}]}]
But it return error following as.
#<Peddler::Errors::InvalidRequestException: Error: You must include a valid ShipmentId with a call to the CreateInboundShipment operation. Get ShipmentId values by calling the CreateInboundShipmentPlan operation. The request to CreateInboundShipment must include only items and quantities that have been previously planned through CreateInboundShipmentPlan. If a ShipmentId is not used to create a shipment within 48 hours it will expire.>
When I tried this on MWS scratch pad, it's working normally.
What's the solution to create the Inbound Shipment on RubyOnRails?

I just solved the issue.
There was an mistake when write the inbound_shipment_item.
inbound_shipment_item should be following as.
inbound_shipment_items = [{:seller_sku=>"SKU", :quantity_shipped=>25, :prep_details=>[{:prep_instruction=>"Labeling", :prep_owner=>"SELLER"}]}]

Related

Unable to save an Entry because matrix field is invalid - Craft CMS 2

I'm trying to save an Entry but Craft errors because of an invalid matrix field. The Entry includes a matrix field but I haven't changed it. I'm trying to edit another field. When I save the entry manually from the admin panel, it saves fine without any errors.
I have researched this problem online and a lot of people were recommending that I provide the matrix's ids when saving the entry. However, even then, I still get an error.
In the code below you'll see that I'm trying to save 3 fields:
Cover Image
Language
Tracks
Each of these fields required me to manually save them because they are relations. That's OK, however, as mentioned earlier, the matrix field (named tracks) errors.
Here's my code below
$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section = "programmes";
$entry = $criteria->first([
"slug" => $programme["slug"]
]);
if ($entry) {
// Update Entry attributes
$entry->getContent()->coverImage = $entry->coverImage->ids();
$entry->getContent()->tracks = $entry->tracks->ids();
$entry->getContent()->language = $entry->language->ids();
// Save Entry
if (!craft()->entries->saveEntry($entry)) {
return $entry->getErrors();
}
}
The error that comes back is the following
Argument 1 passed to Craft\MatrixService::validateBlock() must be an instance of Craft\MatrixBlockModel, string given, called in craft/app/fieldtypes/MatrixFieldType.php on line 451
Including the matrices themselves and not their ids has worked.
$entry->getContent()->tracks = $entry->tracks->all();

Is it possible to call an URL passing website parameters?

I am writing code for a custom SAP program regarding some Vendor information. In my program flow, there is a possibility of me trying to use a Vendor VAT Number that belongs to an unknown Vendor. There is a Web site (EU Based - https://ec.europa.eu/taxation_customs/vies/) for such purposes that requires a country key and the specified VAT Number in order for it to provide an answer with the available Company information (only works for company VAT numbers of course). My problem is that I cannot seem to find any way to pass those parameters dynamically to the Web site without needing the user to interfere during this process. Manually, the process would be to select a country key, type in a VAT number and press 'Verify'.
Is there any way for me to call this specific Web site URL and "bypass" this process to only display the result page? For now, I'm using the following Function Module to just call the specified URL, in lack of any better choices.
call function 'CALL_INTERNET_ADRESS'
exporting
pi_adress = 'https://ec.europa.eu/taxation_customs/vies/'
exceptions
no_input_data = 1
others = 2.
You can use CL_HTTP_CLIENT class or HTTP_POST/HTPP_GET FM.
You need to install given web page SSL root certificate to your system with STRUST t-code.
Example usage of CL_HTTP_CLIENT below.
DATA: lv_url TYPE string VALUE 'http://mkysoft.com/ip.php'.
DATA: o_client TYPE REF TO if_http_client.
DATA: lv_http_rc TYPE i.
DATA: lv_reason TYPE string.
DATA: lt_fields TYPE tihttpnvp.
TRY.
cl_http_client=>create_by_url( EXPORTING
url = lv_url
IMPORTING
client = o_client
EXCEPTIONS
OTHERS = 0 ).
o_client->request->get_header_fields( CHANGING fields = lt_fields ).
o_client->request->set_header_field( name = '~request_uri' value = '/ip.php' ).
o_client->request->set_header_field( name = '~host' value = 'mkysoft.com' ).
o_client->request->set_method( if_http_request=>co_request_method_get ).
o_client->send( ).
o_client->receive( ).
o_client->response->get_status( IMPORTING
code = lv_http_rc
reason = lv_reason ).
* Error check
IF lv_http_rc = 200.
DATA(lv_xml) = o_client->response->get_cdata( ).
* Handle error
ELSE.
WRITE: / 'Fehler: ', lv_http_rc.
ENDIF.
o_client->close( ).
CATCH cx_root INTO DATA(e_txt).
WRITE: / e_txt->get_text( ).
ENDTRY.
EU Commission has a SOAP service for vat numbers.
See the info page
https://ec.europa.eu/taxation_customs/vies/technicalInformation.html
and that it even supports http
http://ec.europa.eu/taxation_customs/vies/checkVatTestService.wsdl
You have a non screen scrape method, proper interface you should look at.
On the other point of Avoiding SSL.
Make a basic guide for customers to add the European commission cert to their SAP system. If someone is complaining about that, then they are a serious user of the internet. Every sap on premise user, that needs to call the internet adds certs.
Http is dead....

How to change a modx revolution users class_key when newly created VIA the manager?

I'm trying to change a new user's class_key value when they are created VIA the manager.
In a plugin that fires on the onUserSave event:
<?php
$uid = $_POST['id'];
$sql = "update modx_users set `class_key` = 'extUser' where id = $uid;";
$modx->log(modX::LOG_LEVEL_ERROR, 'query = ' . $sql);
$query = $modx->query($sql);
return;
Which works when you EDIT an EXISTING user, but does not work if you try to CREATE a NEW user.
Any thoughts on how to do this?
None of the system events look like they fire when a new user is created.
Looking at the user/create processor, you would need to listen for OnUserFormSave which is fired after saving the new user.
I haven't tested this, but in your plugin you have access to $modx->event. Log the output of this for the OnUserFormSave event, hopefully it should include a 'data' property containing the new user object. The object should contain the new user id.
Let me know how that goes!
Update
I've tested this out. As expected, you have access to the new user id, user object (and much more) in the $modx->event object:
if ($modx->event->name == 'OnUserFormSave') {
// id of user you've just created
$newUserId = $modx->event->name->params->id;
// full modUser object is available here
$newUserObj = $modx->event->name->params->user;
}
In plugin with OnUserSave event:
$scriptProperties['user']->set('class_key','extUser');
That's it nothing more.
You cannot call
$scriptProperties['user']->save();
in OnUserSave as other examples elsewhere have shown.

Unit Price Attribute Not Visible in Quickbooks Desktop API

I don't see the Unit Price attribute available in the Item Class when it comes to QBD. Its available in QBO. I am trying to download and fill a database using the items entered via Quickbooks desktop version. Can someone help please?
How can I get the Unit Price for an item in Intuit.Ipp.Data.Qbd.Item?
Extra Information Added after comment by Shivan Raptor (7-Nov-2013)
I am having a Quickbooks Pro Trial 2014 UK version installed in my computer. I have created a company file and items for the company. When I create an item I can enter a Price to that item. Quickbooks must be saving it somewhere. I need to access it using the Quickbooks API from my .Net application.
I am interested on the stock items here. I am using Intuit.Ipp.Data.Qbd.Item class to access it. Am I using the right class? If you go to the API documentation the Item class has a field called Unit Price but its not listed when you actually check from the .Net application.
Shivan Raptor wanted the code (8-Nov-2013)
Given below is the code snippet. If you understand the question properly you would realize it cannot give a run time error because you cannot compile a code if you write it with object attributes that are not exposed. And the compiler error is kind of obvious too:
ATTRIBUTE_NAME not present in CLASS_NAME
In this case, ATTRIBUTE_NAME = UnitPrice and CLASS_NAME = Intuit.Ipp.Data.Qbd.Item (this is already there in the first post itself)
The relevant code sample is given below. Its the code behind of an ASP.Net page.
Try
Dim varItemBL As New BL.ItemManagement
'Preparing Query
Dim qbdItemQuery As New Intuit.Ipp.Data.Qbd.ItemQuery
qbdItemQuery.ItemElementName = Intuit.Ipp.Data.Qbd.ItemChoiceType4.StartPage
qbdItemQuery.Item = "1"
qbdItemQuery.ChunkSize = "10"
'Quering Quickbooks Desktop
Dim qbdItems = qbdItemQuery.ExecuteQuery(Of Intuit.Ipp.Data.Qbd.Item)(context).ToList
'Synchronising Items from Quickbooks to MyDigiRep
For i As Integer = 0 To qbdItems.Count - 1
Dim varUnitPrice As Decimal
'Checking whether Unit Price is entered
If qbdItems(i).UnitPrice Is Nothing Then
varUnitPrice = 0
Else
varUnitPrice = qbdItems(i).UnitPrice.Amount
End If
'Synchronising Item with the MyDigiRep database
varItemBL.fnAddItemsAPI(qbdItems(i).Name, "NS", varUnitPrice, _
qbdItems(i).UOMAbbrv, HttpContext.Current.Session("companyID"), _
qbdItems(i).Id.Value)
Next
'Updating UI to display synchronisation results
lblItemSycnStatus.Text = qbdItems.Count & " Item Records Synchronised."
Catch ex As Exception
lblItemSycnStatus.Text = "Item Records Synchronisation Failed."
End Try
The version of the Intuit.Ipp.Data.dll is 2.1.12.0

Post a proudct with MWS api and Ruby on Rails

I'm trying to upload a new product to mws with the mws api and mws gem
The product is added (like Fix failed listings, because, doen't have a quantity and price)
I'm trying with the next code:
mws = Mws.connect(
merchant: 'merchant',
access: 'access',
secret: 'secret'
)
Later:
product = Mws::Product('11333663') { upc '1234355462233' tax_code
'GEN_TAX_CODE' name 'Some Pduct 034' brand 'Some Bnd' msrp 18.9,
'USD' quantity 10 manufacturer 'Some Mufacturer' category :ce
details {
cable_or_adapter {
cable_length as_distance 5, :feet
} } }
later:
submission_id = mws.feeds.products.add(product)
The product is added, but when I excuted this line:
submission_id = mws.feeds.products.update(product)
The next message is displayed:
=> #<Mws::Apis::Feeds::SubmissionResult:0x9d9ae78 #transaction_id="12345678", #status=#<Mws::EnumEntry:0x9d96170
#sym=:complete, #val="Complete">, #messages_processed=0,
#counts={:success=>0, :error=>1, :warning=>0},
#responses={:"0"=>#, #code=90208, #description="Purge
and replace is not allowed for this feed type.">}>
2.0.0-p195 :050 > result = mws.feeds.get(submission_id.id)
=> #, #messages_processed=1,
#counts={:success=>0, :error=>1, :warning=>0},
#responses={:"0"=>#, #code=90000,
#description="http://sellercentral.amazon.com/myi/search/ErrorListingsSummary?batchId=7564766086">,
:"1"=>#, #code=99042, #description="A
value was not provided for \"item_type\". Please provide a value for
\"item_type\". Please use the Product Classifier or download the
category-specific Browse Tree Guide from Seller Help to see a list of
valid \"item_type\" values. This information tells Amazon where your
product should be classified and affects how easily customers can find
your product.", #additional_info={:sku=>"11333668"}>}>
But, when I tried update the inventory and the price, the follow error ocurred:
result = mws.feeds.get(price_submission_id.id) =>
#sym=:complete, #val="Complete">, #messages_processed=0,
#counts={:success=>0, :error=>1, :warning=>0},
#responses={:"0"=>#, #code=90208, #description="Purge
and replace is not allowed for this feed type.">}>
What can I do?
Without any indepth knowledge of that Ruby Gem (and of Ruby), I can probably still point you in the right direction:
In MWS, feeds automatically update information already in the Amazon database. The call to create a record is identical to a subsequent call to update it. That also means you don't have to keep track of which items were already added to Amazon in the past.
In terms of your Ruby library, you probably should call mws.feeds.products.add(product) for subsequent updates of that product record and not call mws.feeds.products.update(product) at all. The latter seems to create what's called PurgeAndReplace feeds in MWS which you should avoid like the plague.
All other errors you encountered seem to be related to the same root cause.

Resources