Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "google/api_client"
- require "google/api_client/client_secrets"
- require "google/api_client/auth/file_storage"
- module FHQ
- module Repos
- module GooglePlaFeeds
- class SubAccount
- def initialize( merchant_id, auth_file )
- @merchant_id = merchant_id
- @auth_file = auth_file
- end
- def insert( shop )
- client = Google::APIClient.new(
- application_name: "PLA Feeds",
- application_version: "0.0.1"
- )
- file_storage = Google::APIClient::FileStorage.new( auth_file )
- client.authorization = file_storage.authorization
- # DISCOVERED_API NOT WORKING, HENCE HACK
- # content_api = client.discovered_api( "content" )
- content_api = client.discovered_apis.select { |dapi| dapi.id == "content:v2" }.first
- client.execute(
- api_method: content_api.accounts.insert, # <-- This is what is currently failing
- parameters: {
- "merchantId" => merchant_id,
- "websiteUrl" => website_url
- }
- )
- end
- private
- attr_reader :merchant_id, :auth_file
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement