Class: GoogleContentApi::Product

Inherits:
Object
  • Object
show all
Defined in:
lib/google_content_api/product.rb

Class Method Summary collapse

Class Method Details

.createObject



58
59
60
# File 'lib/google_content_api/product.rb', line 58

def create
  raise "not implemented"
end

.create_products(sub_account_id, products, dry_run = false) ⇒ Object Also known as: create_items



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/google_content_api/product.rb', line 6

def create_products(, products, dry_run = false)
  token            = Authorization.fetch_token
  products_url     = GoogleContentApi.urls("products", , :dry_run => dry_run)
  xml              = create_product_items_batch_xml(products)
  Faraday.headers  = {
    "Content-Type"   => "application/atom+xml",
    "Authorization"  => "AuthSub token=#{token}"
  }

  response = Faraday.post products_url, xml

  if response.status == 200
    response
  else
    raise "Unable to batch insert products - received status #{response.status}. body: #{response.body}"
  end
end

.delete(sub_account_id, params) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/google_content_api/product.rb', line 44

def delete(, params)
  token           = Authorization.fetch_token
  product_url     = GoogleContentApi.urls("product", , :language => params[:language], :country => params[:country], :item_id => params[:item_id], :dry_run => params[:dry_run])
  Faraday.headers = { "Authorization" => "AuthSub token=#{token}" }

  response = Faraday.delete product_url

  if response.status == 200
    response
  else
    raise "Unable to delete product - received status #{response.status}. body: #{response.body}"
  end
end

.updateObject



62
63
64
# File 'lib/google_content_api/product.rb', line 62

def update
  raise "not implemented"
end

.update_products(sub_account_id, products, dry_run = false) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/google_content_api/product.rb', line 25

def update_products(, products, dry_run = false)
  token            = Authorization.fetch_token
  products_url     = GoogleContentApi.urls("products", , :dry_run => dry_run)
  @sub_account_id  = 
  xml              = update_product_items_batch_xml(products)
  Faraday.headers  = {
    "Content-Type"   => "application/atom+xml",
    "Authorization"  => "AuthSub token=#{token}"
  }

  response = Faraday.post products_url, xml

  if response.status == 200
    response
  else
    raise "Unable to batch insert products - received status #{response.status}. body: #{response.body}"
  end
end