Class: Pricesphere::Watch
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Pricesphere::Base
Instance Method Details
#register(product_id, webhook_path, callback_params = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pricesphere/watch.rb', line 4 def register(product_id, webhook_path, callback_params = {}) uri = URI.parse(Pricesphere.base_url) http = Net::HTTP.new(uri.host, uri.port) if Pricesphere.base_url =~ /\Ahttps:/ http.use_ssl = true end request = Net::HTTP::Post.new("/api/#{@version}/watches") request.add_field('Content-Type', 'application/json') request.body = { watch: { product_id: product_id, webhook_path: webhook_path, webhook_attributes: callback_params.to_json }, token: @api_key }.to_json response = http.request(request) end |