google-content-api 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da6672a85eabfb10a9c1b87f32e161c20eecfec7
4
- data.tar.gz: 802f067cc36e78b12d508fe0f0ab82f859aad356
3
+ metadata.gz: 278179a947b6f244964810163fb76c4985ed1fe3
4
+ data.tar.gz: c352bae8e0dbb96a9179842c66cd4e2d795107b6
5
5
  SHA512:
6
- metadata.gz: e1a7f059b988ec749a4b9ada5d0fdd4747cdc7e75dd131ea7db74670cc5a0e41c3b7573f88035b7925b19228286bdfc5d7032ce6157fccd50ebcbba26a483f7e
7
- data.tar.gz: ef996e0ffac927fca56be8d2a6c193dd50d162ab4cd0dd9faf404d600ea1d0cf0001b447ca5a451d3f98b57a3afe5fef9a8a33167e4731371471c6d1d953ad17
6
+ metadata.gz: 53a3567008c4d40d0465fe32dc5eed8373e5a08d64e01c09c34a0735683f4efdd01909cf8a279c9abbe460f3dc182c3feb083e36209086857f2f9cea803759b2
7
+ data.tar.gz: 0f8c585dfdece74743c610d7323e5d3154f76503df62151ff8d7fd76de554db6e0ec70fe5b22959200049fd90cb6a5fe8c476f0620a204de12db67d654610ead
@@ -24,6 +24,8 @@ module GoogleContentApi
24
24
  if options[:language].nil? || options[:country].nil? || options[:item_id].nil?
25
25
 
26
26
  "#{base_url}/items/products/generic/online:#{options[:language].downcase}:#{options[:country].upcase}:#{options[:item_id]}?warnings"
27
+ when "item_to_update"
28
+ "#{base_url}/items/products/schema/online:#{options[:language].downcase}:#{options[:country].upcase}:#{options[:item_id]}"
27
29
  else
28
30
  raise "unknown zone"
29
31
  end
@@ -25,6 +25,7 @@ module GoogleContentApi
25
25
  def update_products(sub_account_id, products, dry_run = false)
26
26
  token = Authorization.fetch_token
27
27
  products_url = GoogleContentApi.urls("products", sub_account_id, :dry_run => dry_run)
28
+ @sub_account_id = sub_account_id
28
29
  xml = update_product_items_batch_xml(products)
29
30
  Faraday.headers = {
30
31
  "Content-Type" => "application/atom+xml",
@@ -66,7 +67,7 @@ module GoogleContentApi
66
67
  def create_item_xml(item)
67
68
  item[:id] = item_url(item[:id])
68
69
 
69
- Nokogiri::XML::Builder.new do |xml|
70
+ NokogiriwXML::Builder.new do |xml|
70
71
  xml.entry(
71
72
  'xmlns' => 'http://www.w3.org/2005/Atom',
72
73
  'xmlns:app' => 'http://www.w3.org/2007/app',
@@ -101,16 +102,16 @@ module GoogleContentApi
101
102
  end.to_xml
102
103
  end
103
104
 
104
- def add_mandatory_values(xml, attributes, opts)
105
- xml['batch'].id_ attributes[:id]
106
- xml['sc'].id_ attributes[:id]
107
- xml.title_ attributes[:title]
108
- xml.content_ attributes[:description], :type => 'text'
105
+ def add_mandatory_values(xml, attributes, opts = {})
109
106
  if opts[:type] == 'UPDATE'
110
- xml.link_(:rel => 'edit', :type => 'application/atom+xml', :href => attributes[:link])
107
+ xml.id_ GoogleContentApi.urls("item_to_update", @sub_account_id, :language => attributes[:content_language], :country => attributes[:target_country], :item_id => attributes[:id])
111
108
  else
112
- xml.link_(:rel => 'alternate', :type => 'text/html', :href => attributes[:link])
109
+ xml['batch'].id_ attributes[:id]
113
110
  end
111
+ xml['sc'].id_ attributes[:id]
112
+ xml.title_ attributes[:title]
113
+ xml.content_ attributes[:description], :type => 'text'
114
+ xml.link_(:rel => 'alternate', :type => 'text/html', :href => attributes[:link])
114
115
  xml['sc'].image_link_ attributes[:image]
115
116
  xml['sc'].content_language_ attributes[:content_language]
116
117
  xml['sc'].target_country_ attributes[:target_country]
@@ -119,7 +120,7 @@ module GoogleContentApi
119
120
  xml['scp'].price_ attributes[:price], :unit => attributes[:currency]
120
121
  end
121
122
 
122
- def add_optional_values(xml, attributes, opts)
123
+ def add_optional_values(xml, attributes, opts = {})
123
124
  if attributes[:expiration_date]
124
125
  xml['sc'].expiration_date_ attributes[:expiration_date]
125
126
  end
@@ -1,3 +1,3 @@
1
1
  module GoogleContentApi
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -82,8 +82,8 @@ describe GoogleContentApi::Product do
82
82
  it "creates an xml with all given product attributes" do
83
83
  result_xml = subject.send(:update_product_items_batch_xml, [product_attributes])
84
84
  result_xml.should match 'batch:operation type="UPDATE"'
85
- result_xml.should match 'link.*rel="edit"'
86
- result_xml.should match 'link.*application/atom\+xml'
85
+ result_xml.should_not match 'batch:id'
86
+ result_xml.should match 'items/products/schema/online'
87
87
  product_attributes.each{ |attribute,value| result_xml.should match /#{value}/ }
88
88
  end
89
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-content-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - DaWanda GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-20 00:00:00.000000000 Z
11
+ date: 2014-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler