Sha256: 4dd84e8ca42838ca78db2b437870616f1489bf65412e18bd2c1a1e1c8d6fd272

Contents?: true

Size: 697 Bytes

Versions: 3

Compression:

Stored size: 697 Bytes

Contents

module Pricesphere
  class Watch < Base

    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

    private

    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pricesphere-0.2.2 lib/pricesphere/watch.rb
pricesphere-0.2.1 lib/pricesphere/watch.rb
pricesphere-0.2.0 lib/pricesphere/watch.rb