Sha256: 2c5e87ef279b891a9d39886250a61320d0f907f52ebd5628502aa01cac1df4d9
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
require 'vng/resource' module Vng # Provides methods to interact with Vonigo leads. class Lead < Resource PATH = '/api/v1/data/Leads/' attr_reader :id, :name, :email, :phone def initialize(id:, name:, email:, phone:) @id = id @name = name @email = email @phone = phone end def self.create(name:, email:, phone:) body = { method: '3', Fields: [ {fieldID: 121, optionID: '59'}, {fieldID: 126, fieldValue: name}, {fieldID: 238, fieldValue: URI.encode_uri_component(email)}, {fieldID: 1024, fieldValue: phone}, ] } data = request path: PATH, body: body id = data['Client']['objectID'] name = data['Fields'].find{|field| field['fieldID'] == 126}['fieldValue'] email = data['Fields'].find{|field| field['fieldID'] == 238}['fieldValue'] phone = data['Fields'].find{|field| field['fieldID'] == 1024}['fieldValue'] new id: id, name: name, email: email, phone: phone end # Data validation failed. [{"fieldID"=>0, "fieldName"=>nil, "errNo"=>-1201, "errMsg"=>"Lead ID does not exist."}] # TODO: has become an account meanwhile!! so this doesn't work # def destroy # body = { # method: '4', # objectID: id, # } # # self.class.request path: PATH, body: body # end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vng-0.1.19 | lib/vng/lead.rb |
vng-0.1.18 | lib/vng/lead.rb |