Class: Adknowledge::Integrated

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/adknowledge/integrated.rb

Constant Summary collapse

URL =
'http://integrated.adstation.com'
API_VER =
'1.3'
VALID_FIELDS =
[
  :recipient, :list, :domain, :subid, :sendingdomain, :sendingip,
  :numberofrecipients, :redirect, :countrycode, :metrocode, :state,
  :postalcode, :gender, :dayofbirth, :monthofbirth, :yearofbirth
]
MANDATORY_FIELDS =
[ :recipient, :list, :domain ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Integrated

Create integrated query object

same domain name for the request

Parameters:

  • parameters
  • [Symbol] (Hash)

    a customizable set of options



36
37
38
39
40
41
42
# File 'lib/adknowledge/integrated.rb', line 36

def initialize params={}
  @records = []
  @mapped  = false
  params.each do |k,v|
    send("#{k}=", v)
  end
end

Instance Attribute Details

#cdomainObject

Returns the value of attribute cdomain.



12
13
14
# File 'lib/adknowledge/integrated.rb', line 12

def cdomain
  @cdomain
end

#idomainObject

Returns the value of attribute idomain.



12
13
14
# File 'lib/adknowledge/integrated.rb', line 12

def idomain
  @idomain
end

#recipientsObject

Returns the value of attribute recipients.



11
12
13
# File 'lib/adknowledge/integrated.rb', line 11

def recipients
  @recipients
end

#requestObject (readonly)

Returns the value of attribute request.



11
12
13
# File 'lib/adknowledge/integrated.rb', line 11

def request
  @request
end

#subidObject

Returns the value of attribute subid.



12
13
14
# File 'lib/adknowledge/integrated.rb', line 12

def subid
  @subid
end

#testObject

Returns the value of attribute test.



12
13
14
# File 'lib/adknowledge/integrated.rb', line 12

def test
  @test
end

Instance Method Details

#domain=(dom) ⇒ Symbol

Set both click-domain and image-domain

Parameters:

  • domain (Symbol)

Returns:

  • (Symbol)

    domain



94
95
96
# File 'lib/adknowledge/integrated.rb', line 94

def domain= dom
  self.cdomain = self.idomain = dom
end

#errored_recipientsArray

Return all errored recipients

Returns:

  • (Array)

    errored recipients



85
86
87
88
# File 'lib/adknowledge/integrated.rb', line 85

def errored_recipients
  return [] unless mapped?
  recipients.select{ |r| r['success'] == false }
end

#map!Boolean

Map content for specified recipients

Returns:

  • (Boolean)

    map attempt submitted



65
66
67
68
69
70
71
72
# File 'lib/adknowledge/integrated.rb', line 65

def map!
  unless Adknowledge.token
    raise ArgumentError, 'Adknowledge token required to perform queries'
  end

  merge_recipients! query_result
  @mapped = true
end

#mapped?Boolean

Return confirmation if the mapping query has been run yet

Returns:

  • (Boolean)

    mapped?



114
115
116
# File 'lib/adknowledge/integrated.rb', line 114

def mapped?
  @mapped
end

#mapped_recipientsArray

Return all successfully mapped recipients

Returns:

  • (Array)

    mapped recipients



77
78
79
80
# File 'lib/adknowledge/integrated.rb', line 77

def mapped_recipients
  return [] unless mapped?
  recipients.select{ |r| r['success'] == true }
end

#query_paramsHash

Return the query params that will be sent to Adknowledge integrated API

Returns:

  • (Hash)

    query params



101
102
103
104
105
106
107
108
109
# File 'lib/adknowledge/integrated.rb', line 101

def query_params
  { token:   Adknowledge.token,
    idomain: idomain,
    cdomain: cdomain,
    request: request,
    subid:   subid,
    test:    test ? 1 : 0
  }
end