sellsy-client 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sellsy/contact.rb +49 -3
- data/lib/sellsy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2650575efc5348dd9426aea3c42325c0d6826e15890c5cd702ffb315e2274fe5
|
4
|
+
data.tar.gz: 03b323c8b6f433a6249d6467eb5876ac90c3c4fa93769da564ab1783b61d6641
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f21527b4740706fc96fc0cb18135f84a133404e9072643564c0ad2fe195f399529cf99a0453fa442ba767d4d13c7e1c84f9be742cc9aa016e34d71b5c2190928
|
7
|
+
data.tar.gz: c7e7f4d19fcddd531d190fa3dafd81a5409bb9630f79b0ee0f2013cc15003fd53323f20e594bc78da15d7ca12bdde13f5b674d8aaed7e1778f08c5072e837c8b
|
data/Gemfile.lock
CHANGED
data/lib/sellsy/contact.rb
CHANGED
@@ -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, :
|
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' => @
|
119
|
+
'thirdids' => @third_ids.blank? ? nil : @third_ids
|
74
120
|
}
|
75
121
|
end
|
76
122
|
|
data/lib/sellsy/version.rb
CHANGED
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.
|
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-
|
14
|
+
date: 2020-03-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: multi_json
|