sellsy-client 0.5.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5712404d503192843caec9229007c697f467288f859ed00dce0c6dd2a0ed3d2
4
- data.tar.gz: a489b98d1b10338084346ff06a267cf0cba76d453aa255ff06ed752bcfb7ee03
3
+ metadata.gz: ca7907749f9d9b1df1865191066f068ad034f471ef17f8fb0022db589ca16e9f
4
+ data.tar.gz: c9e87eff0a1001e83da3355dcd7ceaa47ca11ca3c825229dcf11f971757eef12
5
5
  SHA512:
6
- metadata.gz: 15aa7f0a9287d11bbfa4c6aeca313166935a66bbc02ec187be371fce181d1c8f3ccc4251652e8c5481415ca1028ea5eb2885ac471631eb6e13a1ff79991715a1
7
- data.tar.gz: 2a457a8e43dfd21ba577fa7026f8b400b94ef267fea61f736ded84577f5d0588ad2f3f9a88fc9ebf66192142cdf98ad8004d14c7c26590a4c23a0d3928b0fcac
6
+ metadata.gz: cc1523e05af6cb3759eaad5afdd690f537fd20615e218451bc2989c8430b433f81a8669e1e9c2bc2602c195823450d27553b1264730bc2d8732052aaf5387aed
7
+ data.tar.gz: 8197ebf9ab4d1938ce0550a9d95a687d3a43961086d2f139a47e996080877030e1d2367bbd6b51e2df4bd4ab91a0102101337f2b51cf038638c9a35b999b42a0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sellsy-client (0.4.0)
4
+ sellsy-client (0.9.0)
5
5
  multi_json (~> 1.11)
6
6
  rest-client (~> 2.0, >= 2.0.2)
7
7
 
@@ -27,7 +27,7 @@ GEM
27
27
  netrc (~> 0.8)
28
28
  unf (0.1.4)
29
29
  unf_ext
30
- unf_ext (0.0.7.6)
30
+ unf_ext (0.0.7.7)
31
31
 
32
32
  PLATFORMS
33
33
  ruby
@@ -2,8 +2,8 @@ require 'multi_json'
2
2
 
3
3
  module Sellsy
4
4
  class Contact
5
- attr_accessor :id, :title, :name, :first_name, :last_name, :third_id, :email, :telephone, :mobile, :fax, :website,
6
- :role, :birth_date
5
+ attr_accessor :id, :title, :name, :first_name, :last_name, :third_ids, :email, :telephone, :mobile, :fax, :website,
6
+ :role, :birth_date, :linked_type, :linked_id
7
7
 
8
8
  def create
9
9
  command = {
@@ -20,6 +20,19 @@ module Sellsy
20
20
  response['status'] == 'success'
21
21
  end
22
22
 
23
+ def update
24
+ command = {
25
+ 'method' => 'Peoples.update',
26
+ 'params' => {
27
+ 'id' => @id,
28
+ 'people' => to_params
29
+ }
30
+ }
31
+
32
+ response = MultiJson.load(Sellsy::Api.request command)
33
+ response['status'] == 'success'
34
+ end
35
+
23
36
  def self.find(people_id)
24
37
  command = {
25
38
  'method' => 'Peoples.getOne',
@@ -58,6 +71,40 @@ module Sellsy
58
71
  contact
59
72
  end
60
73
 
74
+ def self.search(name, b_date = nil)
75
+ contacts = []
76
+
77
+ unless name.blank?
78
+ command = {
79
+ 'method' => 'Peoples.getList',
80
+ 'params' => {
81
+ 'search' => {
82
+ 'contains' => name,
83
+ 'birthdate' => b_date.blank? ? nil : Date.parse(b_date).to_datetime.to_i,
84
+ }
85
+ }
86
+ }
87
+
88
+ response = MultiJson.load(Sellsy::Api.request command)
89
+
90
+ if response['response']
91
+ response['response']['result'].each do |key, value|
92
+ contact = Contact.new
93
+ contact.id = key
94
+ contact.linked_type = value['linkedtype']
95
+ contact.linked_id = value['linkedid']
96
+ contact.name = value['name']
97
+ contact.first_name = value['forename']
98
+ contact.email = value['email']
99
+ contact.third_ids = ((value['prospectList'] || []) + (value['thirdList'] || []) + (value['supplierList'] || [])).map {|e| e['id']}
100
+ contacts << contact
101
+ end
102
+ end
103
+ end
104
+
105
+ contacts
106
+ end
107
+
61
108
  def to_params
62
109
  {
63
110
  'civil' => civil_enum(@title),
@@ -70,7 +117,7 @@ module Sellsy
70
117
  'web' => @website,
71
118
  'position' => @role,
72
119
  'birthdate' => @birth_date.blank? ? '' : Date.parse(@birth_date).to_datetime.to_i,
73
- 'thirdids' => @third_id.blank? ? nil : [@third_id]
120
+ 'thirdids' => @third_ids.blank? ? nil : @third_ids
74
121
  }
75
122
  end
76
123
 
@@ -41,12 +41,12 @@ module Sellsy
41
41
  end
42
42
  end
43
43
 
44
- def self.all
44
+ def self.all(nb_per_page = 30)
45
45
  command = {
46
46
  'method' => 'CustomFields.getList',
47
47
  'params' => {
48
48
  'pagination' => {
49
- 'nbperpage' => 30
49
+ 'nbperpage' => nb_per_page
50
50
  }
51
51
  }
52
52
  }
@@ -29,7 +29,7 @@ module Sellsy
29
29
 
30
30
  def to_params
31
31
  {
32
- 'id' => @id,
32
+ 'clientid' => @id,
33
33
  'third' => {
34
34
  'name' => person_type == 'pp' ? @name : @structure_name,
35
35
  'type' => person_type == 'pp' ? 'person' : 'corporation',
@@ -61,7 +61,6 @@ module Sellsy
61
61
  value = response['response']['client']
62
62
  client.id = value['id']
63
63
  client.name = value['name']
64
- client.type = value['type']
65
64
  client.contacts = response['response']['contacts']
66
65
  end
67
66
 
@@ -82,6 +81,8 @@ module Sellsy
82
81
  client = Customer.new
83
82
  client.id = key
84
83
  client.name = value['fullName']
84
+ client.email = value['email']
85
+ client.siret = value['siret']
85
86
  clients << client
86
87
  end
87
88
  end
@@ -77,7 +77,7 @@ module Sellsy
77
77
  'dueDate' => (Date.today + 1.month).to_datetime.to_i,
78
78
  'stepid' => step['id'],
79
79
  'contacts' => @contacts.blank? ? nil : @contacts.join(','),
80
- 'stickyNote' => @comments
80
+ 'brief' => @comments
81
81
  }
82
82
  }
83
83
  else
@@ -80,6 +80,8 @@ module Sellsy
80
80
  prospect = Prospect.new
81
81
  prospect.id = key
82
82
  prospect.name = value['fullName']
83
+ prospect.email = value['email']
84
+ prospect.siret = value['siret']
83
85
  prospects << prospect
84
86
  end
85
87
  end
@@ -1,3 +1,3 @@
1
1
  module Sellsy
2
- VERSION = "0.5.0"
2
+ VERSION = "0.10.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sellsy-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Stammers
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-03-29 00:00:00.000000000 Z
14
+ date: 2020-11-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: multi_json