Class: AlPapi::WebInsight

Inherits:
Object
  • Object
show all
Defined in:
lib/al_papi/web_insight.rb

Constant Summary collapse

ENDPOINT =
'/web/insight'

Class Method Summary collapse

Class Method Details

.check_params(params, *param) ⇒ Object

Check if required params exist



41
42
43
44
45
# File 'lib/al_papi/web_insight.rb', line 41

def self.check_params(params, *param)
  param.each do |p|
    fail "#{p} parameter is required." if params[p].nil? || params[p.to_s].empty?
  end
end

.get(params = {}) ⇒ Object

Parameters should be the same url as what was posted to the Partner API and the date_created and time_created values passed back to you via the callback posted.

Parameters:

  • url (String)

    Required - The URL originally posted to Partner API

  • date_created (String)

    Required - The date_created that was returned in the callback.

  • time_created (String)

    Required - The time_created that was returned in the callback.



31
32
33
34
# File 'lib/al_papi/web_insight.rb', line 31

def self.get(params = {})
  check_params Hashie::Mash.new(params), *%w[date_created time_created]
  request 'get', params
end

.post(params = {}) ⇒ Object

URL for the page you want insight into and the callback url you have implemented to know when results are ready to get.

Parameters:

  • url (String)

    Required - The web page you want to gain insight on.

  • callback (String)

    Required - Default is the callback you have set for your account. Set specific callbacks per request by using this paramerter. A POST is sent to this callback URL when results are returned.

Raises:

  • When required parameter is not found.



17
18
19
20
# File 'lib/al_papi/web_insight.rb', line 17

def self.post(params = {})
  check_params Hashie::Mash.new(params), *%w[url callback]
  request 'post', params
end

.request(method, params = {}) ⇒ Object



47
48
49
# File 'lib/al_papi/web_insight.rb', line 47

def self.request(method, params = {})
  AlPapi.http.send method, ENDPOINT, params
end