1

アイテムを eBay に投稿する ruby​​ on rails アプリを作成しようとしています。Cody Fauser/Garry Tan は、ebay gem の上に構築された ebayApi と呼ばれる gem を持っています。商品を投稿しようとすると、ebay から、このカテゴリーにはコンディション ID が必要であるというエラーが返されます。条件を必要としないカテゴリを見つけたので、そのカテゴリに投稿できます。eBay API ドキュメントを検索したところ、"item" クラスの下にタグ conditionID が見つかりました。ただし、ebayAPI のドキュメントには、そのようなタグはありません。eBay API ドキュメントを振り返ると、lookup_attributes を使用して条件を指定する古い方法があります。戻り値の xml は API バージョン 745 で提供される予定であり、Garry Gan の Ruby インターフェイスの更新はバージョン 609 で実行されていることに注意しました。ルックアップを使用してみました。同じエラーが発生するようです(条件が必要です)。次のコードを使用してアイテムを指定しています。

@ebay = Ebay::Api.new :auth_token => @seller.ebay_token
item = Ebay::Types::Item.new( :primary_category => Ebay::Types::Category.new(:category_id => @ebayTemplate.categoryID),
:title => @ebayTemplate.name,
:description => @ebayTemplate.description,
:location => @ebayTemplate.location,
:start_price => Money.new((@ebayTemplate.startPrice*100).to_d, @ebayTemplate.currency),
:quantity => 1,
:listing_duration => @ebayTemplate.listingDuration,
:country => @ebayTemplate.country,
:currency => @ebayTemplate.currency,
:payment_methods => ['VisaMC', 'PayPal'],
:paypal_email_address => '********@gmail.com',
:dispatch_time_max => 3,
:lookup_attributes => [Ebay::Types::LookupAttribute.new( :name => "Condition", :value => "New")],
#         :attribute_sets => [
#           Ebay::Types::AttributeSet.new(
#             :attribute_set_id => 2919,
#             :attributes => [
#               Ebay::Types::Attribute.new(
#                 :attribute_id => 10244,
#                 :values => [ Ebay::Types::Val.new(:value_id => 10425) ]
#               )
#              ]
#           )
#         ],
:shipping_details => Ebay::Types::ShippingDetails.new(
:shipping_service_options => [
#              ShippingServiceOptions.new(
#              :shipping_service_priority => 2, # Display priority in the listing
#              :shipping_service => 'UPSNextDay',
#              :shipping_service_cost => Money.new(1000, 'USD'),
#              :shipping_surcharge => Money.new(299, 'USD')
#             ),
Ebay::Types::ShippingServiceOptions.new(
:shipping_service_priority => 1, # Display priority in the listing
:shipping_service => @ebayTemplate.shipSvc,
:shipping_service_cost => Money.new((@ebayTemplate.shipSvcCost*100).to_d, @ebayTemplate.currency),
:shipping_surcharge => Money.new((@ebayTemplate.shipSurcharge*100).to_d, @ebayTemplate.currency)
)
],
:international_shipping_service_options => [
Ebay::Types::InternationalShippingServiceOptions.new(
:shipping_service => 'USPSPriorityMailInternational',
:shipping_service_cost => Money.new((@ebayTemplate.shipSvcCost*100).to_d, @ebayTemplate.currency),
:shipping_service_priority => 2,
:ship_to_location => @ebayTemplate.shipToLocation
)
]

),
:return_policy => Ebay::Types::ReturnPolicy.new (
:description => 'this product for suckers only!',
:returns_accepted_option => 'ReturnsAccepted'
)
#:condition_id => 1000
)

@response = @ebay.add_item(:item => item)

ご覧のとおり、これは Cody Fauser が示した例を変更したにすぎません。そのような属性がないため、一番下の condition_id でエラーが発生します。ジェムが作成された後に要件が存在するようになったため、ジェムにはこれのための機能がないように思えます。eBay に接続する他の宝石を見つけることができませんでした。また、人々がまだ宝石をダウンロードしているにもかかわらず、これについての苦情はほとんどないことに気付きました (今日は 10 人がダウンロードしました)。ebayに書いている人はかなり多いと思います。条件を指定するために欠落しているキーワードはありますか? 人々が使用している回避策はありますか?私が逃した別の宝石?

4

1 に答える 1

0

gemのtypeディレクトリに既存のitem_conditions_codes.rbがあり、NewとUsedの2つの値しかありません。そこにさらに値を追加できると思います。ただし、更新(および属性から変更)メソッドごとにIDにマッピングする必要があります

..のgemライブラリを変更しruby/1.8/gems/ebayapi-0.12.0/lib/ebay/types/item.rb 、次の新しい行を追加する必要があります

# added to allow ConditionID to be pushed into XML
numeric_node :condition_id, 'ConditionID', :optional => true

次に、rubyebayコードで次の規則を使用します

:condition_id => 1500,

少なくとも今はそれでうまくいくようです。

于 2012-08-09T06:10:22.067 に答える