Class: Traction::WebConnection
- Inherits:
-
Object
- Object
- Traction::WebConnection
- Defined in:
- lib/traction/web_connection.rb
Overview
Creates a new WebConnection object to contain wrapped API methods associated with a particular WebConnection, or Function, in Traction API terminology.
Method examples use the hypothetical namespaces from the configuration example.
Constant Summary collapse
- DOMAIN =
"int.api.tractionplatform.com"
Instance Method Summary collapse
-
#add_competition_entrant(details, entry_code, subscribe = true, optional_data = {}) ⇒ Object
Competition method for adding an entrant to (or removing an entrant from) a competition.
-
#add_customer(details, optional_data = {}) ⇒ Object
Registration method for adding a customer to the campaign customer list.
-
#add_customer_with_group_and_subscription(details, groups = {}, subscriptions = {}) ⇒ Object
Registration method for adding a customer to the campaign customer list, and associating the customer with (or dissociating a customer from) groups and/or subscriptions.
-
#draw_competition(venue_ids = []) ⇒ Object
Competition method for drawing the competition winner/s.
-
#get_customer_by(field, value, attributes = []) ⇒ Object
Registration method for retrieving attributes for a customer, searching against a given field.
-
#initialize(path, password) ⇒ WebConnection
constructor
A new instance of WebConnection.
-
#redeem_winner(field, value, venue_id, redemption_code, optional_data = {}) ⇒ Object
Competition method for providing redemption code to a winner.
-
#send_triggered_email(email, optional_data = {}) ⇒ Object
Triggered Message method for sending a triggered email to a subscriber.
-
#validate_entry(field, value, entry_code) ⇒ Object
Competition method for validating a potential entry to a competition.
-
#web_registration(details, optional_data = {}) ⇒ Object
Registration method for adding a customer directly to an associated email list, selected on creation of the function in traction.
Constructor Details
#initialize(path, password) ⇒ WebConnection
Returns a new instance of WebConnection.
13 14 15 16 |
# File 'lib/traction/web_connection.rb', line 13 def initialize(path, password) @path = path @password = password end |
Instance Method Details
#add_competition_entrant(details, entry_code, subscribe = true, optional_data = {}) ⇒ Object
Competition method for adding an entrant to (or removing an entrant from) a competition.
194 195 196 197 198 199 200 201 |
# File 'lib/traction/web_connection.rb', line 194 def add_competition_entrant(details, entry_code, subscribe=true, optional_data={}) body = {customer: details, entryCode: entry_code, subscribe: subscribe, transData: optional_data} get_response_for(body) end |
#add_customer(details, optional_data = {}) ⇒ Object
Registration method for adding a customer to the campaign customer list.
77 78 79 80 81 82 |
# File 'lib/traction/web_connection.rb', line 77 def add_customer(details, optional_data={}) body = {customer: details, transData: optional_data} get_response_for(body) end |
#add_customer_with_group_and_subscription(details, groups = {}, subscriptions = {}) ⇒ Object
Registration method for adding a customer to the campaign customer list, and associating the customer with (or dissociating a customer from) groups and/or subscriptions.
104 105 106 107 108 109 110 |
# File 'lib/traction/web_connection.rb', line 104 def add_customer_with_group_and_subscription(details, groups={}, subscriptions={}) body = {customer: details, groups: groups, subscriptions: subscriptions} get_response_for(body) end |
#draw_competition(venue_ids = []) ⇒ Object
Competition method for drawing the competition winner/s.
220 221 222 223 224 225 |
# File 'lib/traction/web_connection.rb', line 220 def draw_competition(venue_ids=[]) body = {mode: "DRAW"} body[:venueIdList] = venue_ids if venue_ids.any? get_response_for(body) end |
#get_customer_by(field, value, attributes = []) ⇒ Object
Registration method for retrieving attributes for a customer, searching against a given field.
49 50 51 52 53 54 |
# File 'lib/traction/web_connection.rb', line 49 def get_customer_by(field, value, attributes=[]) body = {customerLookup: {field => value}, customerAttributes: attributes} get_response_for(body) end |
#redeem_winner(field, value, venue_id, redemption_code, optional_data = {}) ⇒ Object
Competition method for providing redemption code to a winner.
255 256 257 258 259 260 261 262 263 |
# File 'lib/traction/web_connection.rb', line 255 def redeem_winner(field, value, venue_id, redemption_code, optional_data={}) body = {mode: "REDEEM", customer: {field => value}, venueId: venue_id, redemptionCode: redemption_code, transData: optional_data} get_response_for(body) end |
#send_triggered_email(email, optional_data = {}) ⇒ Object
Triggered Message method for sending a triggered email to a subscriber. The content of the email can be personalised with optional data, but should already exist in traction.
287 288 289 290 291 292 |
# File 'lib/traction/web_connection.rb', line 287 def send_triggered_email(email, optional_data={}) body = {customer: {EMAIL: email}, transData: optional_data} get_response_for(body) end |
#validate_entry(field, value, entry_code) ⇒ Object
Competition method for validating a potential entry to a competition.
163 164 165 166 167 168 169 |
# File 'lib/traction/web_connection.rb', line 163 def validate_entry(field, value, entry_code) body = {mode: "VALIDATE", customer: {field => value}, entryCode: entry_code} get_response_for(body) end |
#web_registration(details, optional_data = {}) ⇒ Object
Registration method for adding a customer directly to an associated email list, selected on creation of the function in traction.
134 135 136 137 138 139 |
# File 'lib/traction/web_connection.rb', line 134 def web_registration(details, optional_data={}) body = {customer: details, transData: optional_data} get_response_for(body) end |