Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. require "google/api_client"
  2. require "google/api_client/client_secrets"
  3. require "google/api_client/auth/file_storage"
  4.  
  5. module FHQ
  6. module Repos
  7. module GooglePlaFeeds
  8.  
  9. class SubAccount
  10.  
  11. def initialize( merchant_id, auth_file )
  12. @merchant_id = merchant_id
  13. @auth_file = auth_file
  14. end
  15.  
  16. def insert( shop )
  17. client = Google::APIClient.new(
  18. application_name: "PLA Feeds",
  19. application_version: "0.0.1"
  20. )
  21.  
  22. file_storage = Google::APIClient::FileStorage.new( auth_file )
  23. client.authorization = file_storage.authorization
  24.  
  25. # DISCOVERED_API NOT WORKING, HENCE HACK
  26. # content_api = client.discovered_api( "content" )
  27. content_api = client.discovered_apis.select { |dapi| dapi.id == "content:v2" }.first
  28.  
  29. client.execute(
  30. api_method: content_api.accounts.insert, # <-- This is what is currently failing
  31. parameters: {
  32. "merchantId" => merchant_id,
  33. "websiteUrl" => website_url
  34. }
  35. )
  36. end
  37.  
  38. private
  39. attr_reader :merchant_id, :auth_file
  40. end
  41.  
  42. end
  43. end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement