Class: Bing::Content::Api::Client
- Inherits:
-
Object
- Object
- Bing::Content::Api::Client
- Defined in:
- lib/bing/content/api/client.rb
Constant Summary collapse
- REDIRECT_URI =
"https://login.live.com/oauth20_desktop.srf".freeze
Instance Attribute Summary collapse
-
#developer_token ⇒ Object
readonly
Returns the value of attribute developer_token.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#refresh_token_callback ⇒ Object
Returns the value of attribute refresh_token_callback.
Instance Method Summary collapse
- #fetch_token_with_code!(verified_url) ⇒ Object
- #generate_user_authorisation_url ⇒ Object
-
#initialize(client_id, developer_token, merchant_id, refresh_token = nil, catalogue_id = nil) ⇒ Client
constructor
A new instance of Client.
- #retrieve_catalogue ⇒ Object
- #run_batch(batch) ⇒ Object
Constructor Details
#initialize(client_id, developer_token, merchant_id, refresh_token = nil, catalogue_id = nil) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 |
# File 'lib/bing/content/api/client.rb', line 13 def initialize(client_id, developer_token, merchant_id, refresh_token=nil, catalogue_id=nil) @client_id = client_id @developer_token = developer_token @merchant_id = merchant_id @refresh_token = refresh_token @catalogue_id = catalogue_id @token = nil @refresh_token_callback = nil end |
Instance Attribute Details
#developer_token ⇒ Object (readonly)
Returns the value of attribute developer_token.
9 10 11 |
# File 'lib/bing/content/api/client.rb', line 9 def developer_token @developer_token end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
8 9 10 |
# File 'lib/bing/content/api/client.rb', line 8 def refresh_token @refresh_token end |
#refresh_token_callback ⇒ Object
Returns the value of attribute refresh_token_callback.
7 8 9 |
# File 'lib/bing/content/api/client.rb', line 7 def refresh_token_callback @refresh_token_callback end |
Instance Method Details
#fetch_token_with_code!(verified_url) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/bing/content/api/client.rb', line 29 def fetch_token_with_code!(verified_url) @token = oauth_client.auth_code.get_token( extract_code(verified_url), :redirect_uri => REDIRECT_URI ) self.refresh_token = @token.refresh_token end |
#generate_user_authorisation_url ⇒ Object
23 24 25 26 27 |
# File 'lib/bing/content/api/client.rb', line 23 def oauth_client.auth_code.( :state => "ArizonaIsAState", :scope => "bingads.manage") end |
#retrieve_catalogue ⇒ Object
42 43 44 45 |
# File 'lib/bing/content/api/client.rb', line 42 def retrieve_catalogue response = connector.get('/products') JSON.parse(response.body)["resources"] end |
#run_batch(batch) ⇒ Object
37 38 39 40 |
# File 'lib/bing/content/api/client.rb', line 37 def run_batch(batch) batch_processor = Bing::Content::Api::BatchProcessor.new(connector) batch_processor.execute(batch) end |