Class: TestrdGem::LeadStorage
- Inherits:
-
Object
- Object
- TestrdGem::LeadStorage
- Defined in:
- lib/testrd_gem/lead_storage.rb
Constant Summary collapse
- @@index =
0
- @@leads =
[]
Class Method Summary collapse
- .all ⇒ Object
- .count ⇒ Object
- .delete(id) ⇒ Object
- .integrate(username, password, token, lead_params) ⇒ Object
- .show(id) ⇒ Object
Instance Method Summary collapse
-
#initialize(name, last_name, email, company, job_title, phone, website) ⇒ LeadStorage
constructor
A new instance of LeadStorage.
Constructor Details
#initialize(name, last_name, email, company, job_title, phone, website) ⇒ LeadStorage
Returns a new instance of LeadStorage.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/testrd_gem/lead_storage.rb', line 7 def initialize(name, last_name, email, company, job_title, phone, website) lead = {} lead[:id] = @@index lead[:name] = name lead[:last_name] = last_name lead[:email] = email lead[:company] = company lead[:job_title] = job_title lead[:phone] = phone lead[:website] = website @@index += 1 @@leads.push(lead) end |
Class Method Details
.all ⇒ Object
26 27 28 |
# File 'lib/testrd_gem/lead_storage.rb', line 26 def self.all @@leads end |
.count ⇒ Object
22 23 24 |
# File 'lib/testrd_gem/lead_storage.rb', line 22 def self.count @@leads.count end |
.delete(id) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/testrd_gem/lead_storage.rb', line 39 def self.delete(id) idx_del = nil size = @@leads.count for i in 0..size-1 if @@leads[i][:id] == id idx_del = i end end if idx_del @@leads.delete_at(idx_del) end end |
.integrate(username, password, token, lead_params) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/testrd_gem/lead_storage.rb', line 53 def self.integrate(username, password, token, lead_params) client = Databasedotcom::Client.new :client_id => "3MVG9KI2HHAq33Rx7XIyfKc5aKIGHGMyvxp9bZHTRZNs1wZs_QI613iMloL9d2waIFXna4oWqvTuJmyMaFJtY", :client_secret => "6763675580231888688" client.authenticate :username => username, :password => password + token lead_class = client.materialize("Lead") client.create(lead_class, lead_params) end |
.show(id) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/testrd_gem/lead_storage.rb', line 30 def self.show(id) for lead in @@leads if lead[:id] == id return lead end end return nil end |