2011-11-18 2 views
1

나는 eBay에 항목을 게시하는 레일즈 응용 프로그램에 루비를 쓰려고합니다. Cody Fauser/Garry Tan에는 ebayApi라고 불리는 보석이 있습니다.이 보석은 이베이 보석 위에 만들어졌습니다. 항목 게시를 시도 할 때이 카테고리에 조건 ID가 필요하다고 말하는 ebay에서 오류가 발생합니다. 조건을 필요로하지 않는 카테고리를 찾았으며 해당 카테고리에 게시 할 수 있습니다. eBay API 설명서를 검색하면서 "item"클래스 아래에 conditionID 태그가 있습니다. 그러나 ebayAPI의 설명서에는 해당 태그가 없습니다. ebay API 문서를 보면 lookup_attributes를 사용하여 이전에 조건을 지정할 수 있습니다. 리턴 XML이 API 버전 745에 들어 왔고 Garry Gan의 루비 인터페이스 업데이트가 버전 609를 실행 중임을 지적했습니다. 조회를 사용해 보았는데 동일한 오류 (조건이 필요함)가있는 것 같습니다. 다음 코드를 사용하여 항목을 지정합니다.Ruby add_item for eBay

@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는 해당 속성이 없으므로 오류가 발생합니다. 보석이 만들어지면 요구 사항이 생겨난 이후로 나에게 보석을위한 시설이 없다고 생각됩니다. 나는 이베이와 연결할 다른 보석을 찾을 수 없었습니다. 나는 또한 사람들이 여전히 보석을 다운로드하고 있음에도 불구하고 이에 대한 불만이 거의 없다는 사실을 발견했다. (오늘 10 명이 그것을 다운로드했다.) 나는 많은 사람들이 eBay를 위해 글을 쓰고 있다고 생각한다. 조건을 지정하기 위해 누락 된 핵심 단어가 있습니까? 그 사람들에 관한 일이 사용되어 왔습니까? 내가 놓친 또 다른 보석?

답변

0

보석 유형 디렉토리에 기존 item_conditions_codes.rb가 있으며 새 값과 사용 된 값이 두 개 있습니다. 거기에 더 많은 가치를 추가 할 수있을 것 같네요. 그러나 여전히 ID의 업데이트 당에 매핑이 필요합니다 (및 속성 변경)

방법 당신의 보석 도서관에서 수정해야 ... 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 

를 추가 이베이 코드는 다음 규칙을 사용합니다

:condition_id => 1500, 

적어도 저에게는 지금 당장 효과가있는 것 같습니다.