sellsy-client 0.5.0 → 0.6.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: 2650575efc5348dd9426aea3c42325c0d6826e15890c5cd702ffb315e2274fe5
4
+ data.tar.gz: 03b323c8b6f433a6249d6467eb5876ac90c3c4fa93769da564ab1783b61d6641
5
5
  SHA512:
6
- metadata.gz: 15aa7f0a9287d11bbfa4c6aeca313166935a66bbc02ec187be371fce181d1c8f3ccc4251652e8c5481415ca1028ea5eb2885ac471631eb6e13a1ff79991715a1
7
- data.tar.gz: 2a457a8e43dfd21ba577fa7026f8b400b94ef267fea61f736ded84577f5d0588ad2f3f9a88fc9ebf66192142cdf98ad8004d14c7c26590a4c23a0d3928b0fcac
6
+ metadata.gz: f21527b4740706fc96fc0cb18135f84a133404e9072643564c0ad2fe195f399529cf99a0453fa442ba767d4d13c7e1c84f9be742cc9aa016e34d71b5c2190928
7
+ data.tar.gz: c7e7f4d19fcddd531d190fa3dafd81a5409bb9630f79b0ee0f2013cc15003fd53323f20e594bc78da15d7ca12bdde13f5b674d8aaed7e1778f08c5072e837c8b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sellsy-client (0.4.0)
4
+ sellsy-client (0.5.0)
5
5
  multi_json (~> 1.11)
6
6
  rest-client (~> 2.0, >= 2.0.2)
7
7
 
@@ -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,39 @@ module Sellsy
58
71
  contact
59
72
  end
60
73
 
74
+ def self.search(name, b_date)
75
+ contacts = []
76
+
77
+ unless name.blank? || b_date.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.third_ids = ((value['prospectList'] || []) + (value['thirdList'] || []) + (value['supplierList'] || [])).map {|e| e['id']}
99
+ contacts << contact
100
+ end
101
+ end
102
+ end
103
+
104
+ contacts
105
+ end
106
+
61
107
  def to_params
62
108
  {
63
109
  'civil' => civil_enum(@title),
@@ -70,7 +116,7 @@ module Sellsy
70
116
  'web' => @website,
71
117
  'position' => @role,
72
118
  'birthdate' => @birth_date.blank? ? '' : Date.parse(@birth_date).to_datetime.to_i,
73
- 'thirdids' => @third_id.blank? ? nil : [@third_id]
119
+ 'thirdids' => @third_ids.blank? ? nil : @third_ids
74
120
  }
75
121
  end
76
122
 
@@ -1,3 +1,3 @@
1
1
  module Sellsy
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.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.6.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-03-31 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: multi_json