Class: CTM::Call
Constant Summary collapse
- ReadOnlyFields =
[ :id, :account_id, :search, :referrer, :location, :source, :likelihood, :duration, :talk_time, :ring_time, :called_at, :tracking_number, :business_number, :dial_status, :caller_number_split, :excluded, :tracking_number_format, :business_number_format, :caller_number_format, :audio, :tag_list, :latitude, :longitude, :extended_lookup ]
- ReadWriteFields =
[ :name, :email, :street, :city, :state, :country, :postal_code, :notes ]
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(data, token = nil) ⇒ Call
constructor
Ca”,“search”:null,“referrer”:null,“location”:null,“source”:“Facebook”,“source_id”:36,“likelihood”:null,“duration”:25, “talk_time”:10,“ring_time”:15,“email”:“[email protected]”,“street”:“1600 Amphitheatre”,“city”:“Escondido”,“state”:“CA”,“country”:“US”,“postal_code”:“94043”, “called_at”:“2013-05-01 11:48 PM -04:00”,“tracking_number_id”:41,“tracking_number”:“+17203584118”,“tracking_label”:null,“business_number”:“+14109759000”,“business_label”:“Main Office”, “receiving_number_id”:9,“dial_status”:“completed”,“caller_number_split”:,“excluded”:false,“tracking_number_format”:“(720) 358-4118”, “business_number_format”:“(410) 975-9000”,“caller_number_format”:“(760) 705-8888”,“alternative_number”:“(760) 705-8888”,“caller_number_complete”:“+17607058888”, “caller_number”:“+17607058888”,“visitor”:false,“audio”:“calltrackingmetrics.com/accounts/ACe2a2cc9e29744544bfa706ba45ad9baf/recordings/RE18e40e5aad04e7a35da0b54ba47895da”, “tag_list”:[“follow up”],“notes”:“”,“latitude”:33.0879,“longitude”:-117.116,“extended_lookup_on”:false,“extended_lookup”:{“first_name”:“”,“last_name”:“”,“name_type”:“”,“phone_type”:“0”,“business_name”:null,“street_number”:“1600”,“street_name”:“Amphitheatre”,“city”:“Mountain View”,“state”:“CA”,“zipcode”:“94043”}.
- #sale ⇒ Object
- #save(options = {}) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(data, token = nil) ⇒ Call
Ca”,“search”:null,“referrer”:null,“location”:null,“source”:“Facebook”,“source_id”:36,“likelihood”:null,“duration”:25, “talk_time”:10,“ring_time”:15,“email”:“[email protected]”,“street”:“1600 Amphitheatre”,“city”:“Escondido”,“state”:“CA”,“country”:“US”,“postal_code”:“94043”, “called_at”:“2013-05-01 11:48 PM -04:00”,“tracking_number_id”:41,“tracking_number”:“+17203584118”,“tracking_label”:null,“business_number”:“+14109759000”,“business_label”:“Main Office”, “receiving_number_id”:9,“dial_status”:“completed”,“caller_number_split”:,“excluded”:false,“tracking_number_format”:“(720) 358-4118”, “business_number_format”:“(410) 975-9000”,“caller_number_format”:“(760) 705-8888”,“alternative_number”:“(760) 705-8888”,“caller_number_complete”:“+17607058888”, “caller_number”:“+17607058888”,“visitor”:false,“audio”:“calltrackingmetrics.com/accounts/ACe2a2cc9e29744544bfa706ba45ad9baf/recordings/RE18e40e5aad04e7a35da0b54ba47895da”, “tag_list”:[“follow up”],“notes”:“”,“latitude”:33.0879,“longitude”:-117.116,“extended_lookup_on”:false,“extended_lookup”:{“first_name”:“”,“last_name”:“”,“name_type”:“”,“phone_type”:“0”,“business_name”:null,“street_number”:“1600”,“street_name”:“Amphitheatre”,“city”:“Mountain View”,“state”:“CA”,“zipcode”:“94043”}
22 23 24 25 26 27 28 29 30 |
# File 'lib/ctm/call.rb', line 22 def initialize(data, token=nil) super(data, token) ReadOnlyFields.each do|field| instance_variable_set("@#{field}", data[field.to_s]) end ReadWriteFields.each do|field| instance_variable_set("@#{field}", data[field.to_s]) end end |
Instance Method Details
#sale ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ctm/call.rb', line 47 def sale path_str = "/api/v1/#{@list_type_path}/#{self.id}/sale.json" res = self.class.get path_str, query: {auth_token: @token} data = res.parsed_response if data["status"] && data["status"] == "error" raise CTM::Error::Sale.new(data["message"] || data ["reason"]) end data['account_id'] = @account_id data['call_id'] ||= self.id CTM::Sale.new(data, @token) end |
#save(options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ctm/call.rb', line 32 def save(={}) #puts "save: #{options.inspect}" path_str = "/api/v1/#{@list_type_path}/#{@id}/modify.json" = {} ReadWriteFields.each do |field| [field == :notes ? :comments : field] = self.send field end [:call] = ([:call] || {}).merge #puts path_str self.class.put(path_str, :body => .merge(:auth_token => @token)) end |