lib/sellsy/prospect.rb in sellsy-client-0.1.0 vs lib/sellsy/prospect.rb in sellsy-client-0.2.0
- old
+ new
@@ -1,13 +1,12 @@
require 'multi_json'
module Sellsy
class Prospect
-
attr_accessor :id, :title, :name, :first_name, :last_name, :structure_name, :category, :college_type, :siret,
:ape, :legal_type, :role, :birth_date, :address, :postal_code, :town, :country, :telephone, :email,
- :website, :payment_method, :person_type, :apidae_member_id
+ :website, :payment_method, :person_type, :apidae_member_id, :main_contact_id
def create
command = {
'method' => 'Prospects.create',
'params' => api_params
@@ -28,10 +27,11 @@
response['status'] == 'success'
end
def api_params
{
+ 'id' => @id,
'third' => {
'name' => person_type == 'pp' ? @name : @structure_name,
'type' => person_type == 'pp' ? 'person' : 'corporation',
'email' => @email,
'web' => @website,
@@ -45,15 +45,16 @@
'forename' => @first_name,
'email' => @email,
'tel' => @telephone,
'mobile' => @telephone,
'position' => @role,
+ 'birthdate' => @birth_date.blank? ? '' : Date.parse(@birth_date).to_datetime.to_i
},
'address' => {
- 'name' => 'adresse souscription',
+ 'name' => 'Adresse principale',
'part1' => @address.split(/(\r\n?)/)[0],
- 'part2' => @address.split(/(\r\n?)/)[0],
+ 'part2' => @address.split(/(\r\n?)/)[1],
'zip' => @postal_code,
'town' => @town,
'countrycode' => @country.upcase
}
}
@@ -73,9 +74,10 @@
if response['response']
value = response['response']['client']
prospect.id = value['id']
prospect.name = value['name']
+ prospect.main_contact_id = value['maincontactid']
end
return prospect
end