Class: Bing::Content::Api::Connector
- Inherits:
-
Object
- Object
- Bing::Content::Api::Connector
- Defined in:
- lib/bing/content/api/connector.rb
Constant Summary collapse
- BMC_HOST =
"https://su1.content.api.bingads.microsoft.com".freeze
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize(developer_token, token, merchant_id, catalogue_id) ⇒ Connector
constructor
A new instance of Connector.
- #post(path, body) ⇒ Object
Constructor Details
#initialize(developer_token, token, merchant_id, catalogue_id) ⇒ Connector
Returns a new instance of Connector.
9 10 11 12 13 14 |
# File 'lib/bing/content/api/connector.rb', line 9 def initialize(developer_token, token, merchant_id, catalogue_id) @developer_token = developer_token @token = token @merchant_id = merchant_id @catalogue_id = catalogue_id end |
Instance Method Details
#get(path) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/bing/content/api/connector.rb', line 16 def get(path) request = HTTPI::Request.new request.url = BMC_HOST + base_uri + path request.headers['Content-Type'] = 'application/json' add_auth_headers(request) HTTPI.get(request) end |
#post(path, body) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bing/content/api/connector.rb', line 24 def post(path, body) request = HTTPI::Request.new params = { :"bmc-catalog-id" => @catalogue_id } if @catalogue_id url = BMC_HOST + base_uri + path_with_params(path, params) request.url = url request.body = body request.headers['Content-Type'] = 'application/json' add_auth_headers(request) HTTPI.post(request) end |