Module: Infusion
- Defined in:
- lib/infusion.rb,
lib/infusion/version.rb
Constant Summary collapse
- VERSION =
"0.0.12"
Class Method Summary collapse
-
.add_contact(contact) ⇒ Object
method for contact add.
-
.campaign(results, campaign_id) ⇒ Object
method for add contact to campaign.
-
.data_load(table, id, selected_fields) ⇒ Object
method for get the data from the table.
- .file_path(file) ⇒ Object
-
.findByEmail(email, contact_info) ⇒ Object
method for find email from IS.
-
.merge(user_id, merge_id) ⇒ Object
method for merge contacts.
-
.optin(email, message) ⇒ Object
method to opt in email.
-
.order(query, fields) ⇒ Object
Find the order from contact id.
-
.orderitems(query, fields) ⇒ Object
Find the order iteams from order_id.
-
.query(query, fields) ⇒ Object
find by query this method is for to check subscription.
-
.update(user_id, contact) ⇒ Object
method for update the contact_info.
Instance Method Summary collapse
-
#method_missing(method, *args, &block) ⇒ Object
Delegate to ApiInfusionsoft::Client.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Delegate to ApiInfusionsoft::Client
154 155 156 157 |
# File 'lib/infusion.rb', line 154 def method_missing(method, *args, &block) return super unless new.respond_to?(method) new.send(method, *args, &block) end |
Class Method Details
.add_contact(contact) ⇒ Object
method for contact add
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/infusion.rb', line 56 def self.add_contact(contact) attempts = 0 begin $server.call("ContactService.add", $key, contact) rescue Exception attempts += 1 retry unless attempts > 1000 exit -1 ensure puts "ensure! #{attempts}" end end |
.campaign(results, campaign_id) ⇒ Object
method for add contact to campaign
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/infusion.rb', line 98 def self.campaign(results, campaign_id) attempts = 0 begin $server.call("ContactService.addToGroup",$key,results,campaign_id) rescue Exception attempts += 1 retry unless attempts > 1000 exit -1 ensure puts "ensure! #{attempts}" end end |
.data_load(table, id, selected_fields) ⇒ Object
method for get the data from the table
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/infusion.rb', line 22 def self.data_load(table, id, selected_fields) attempts = 0 begin main_product = $server.call("DataService.load", $key,table, id, selected_fields) rescue Exception attempts += 1 retry unless attempts > 1000 exit -1 ensure puts "ensure! #{attempts}" end end |
.file_path(file) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/infusion.rb', line 9 def self.file_path(file) begin config = YAML::load(IO.read(file)) rescue => e raise "YAML configuration file couldn't be found: #{e}" end $key = config["key"] server = config["server"] $server = XMLRPC::Client.new2(server) end |
.findByEmail(email, contact_info) ⇒ Object
method for find email from IS
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/infusion.rb', line 42 def self.findByEmail(email, contact_info) attempts = 0 begin $server.call("ContactService.findByEmail", $key, email,contact_info) rescue Exception attempts += 1 retry unless attempts > 1000 exit -1 ensure puts "ensure! #{attempts}" end end |
.merge(user_id, merge_id) ⇒ Object
method for merge contacts
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/infusion.rb', line 84 def self.merge(user_id, merge_id) attempts = 0 begin $server.call("ContactService.merge", $key,user_id, merge_id) rescue Exception attempts += 1 retry unless attempts > 1000 exit -1 ensure puts "ensure! #{attempts}" end end |
.optin(email, message) ⇒ Object
method to opt in email
37 38 39 |
# File 'lib/infusion.rb', line 37 def self.optin(email, ) $server.call("APIEmailService.optIn", $key,email,) end |
.order(query, fields) ⇒ Object
Find the order from contact id
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/infusion.rb', line 126 def self.order(query, fields) attempts = 0 begin $server.call("DataService.query",key,"Job",10,0,query,fields ) rescue Exception attempts += 1 retry unless attempts > 1000 exit -1 ensure puts "ensure! #{attempts}" end end |
.orderitems(query, fields) ⇒ Object
Find the order iteams from order_id
140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/infusion.rb', line 140 def self.orderitems(query, fields) attempts = 0 begin $server.call("DataService.query",key,"OrderItem",10,0,query,fields ) rescue Exception attempts += 1 retry unless attempts > 1000 exit -1 ensure puts "ensure! #{attempts}" end end |
.query(query, fields) ⇒ Object
find by query this method is for to check subscription
112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/infusion.rb', line 112 def self.query(query, fields) attempts = 0 begin $server.call("DataService.query",$key,"RecurringOrder",10,0,query,fields) rescue Exception attempts += 1 retry unless attempts > 1000 exit -1 ensure puts "ensure! #{attempts}" end end |
.update(user_id, contact) ⇒ Object
method for update the contact_info
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/infusion.rb', line 70 def self.update(user_id, contact) attempts = 0 begin $server.call("ContactService.update", $key,user_id,contact) rescue Exception attempts += 1 retry unless attempts > 1000 exit -1 ensure puts "ensure! #{attempts}" end end |