tfso 0.10.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tfso.rb +4 -2
- data/lib/tfso/authentication.rb +6 -4
- data/lib/tfso/client.rb +2 -1
- data/lib/tfso/company.rb +5 -4
- data/lib/tfso/errors.rb +5 -0
- data/lib/tfso/helpers.rb +6 -1
- data/lib/tfso/invoice.rb +17 -8
- data/lib/tfso/payment.rb +2 -1
- data/lib/tfso/person.rb +47 -0
- data/lib/tfso/product.rb +1 -1
- data/lib/tfso/version.rb +1 -1
- data/tfso.gemspec +3 -3
- metadata +21 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c09729d8fa58e87a400ba413c980bd4b7f3c965462e8ad0954299e2bb5f8004
|
4
|
+
data.tar.gz: 8a23d5ca195d50977d5d83c8c1cb454f3f276a266144b3569805c3429359b862
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bcfb80059da00bc081e9f309089ca6027b31c337ebd64a2296cc2de6f1f25bfe870eec4d4e00ccb6978fdba3daa620da8f0d483c3317eecef6c966e75948121
|
7
|
+
data.tar.gz: 76a11939ea64f11c4345630dbe29369b934fd7e0b11d2422257e1ab1d3d374a5ab5d35f2e82f47596b9d35efaa9fab510469f259d9e04be0ad3cd2636a854b75
|
data/lib/tfso.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'savon'
|
2
|
-
require
|
2
|
+
require 'tfso/version'
|
3
3
|
require 'tfso/helpers'
|
4
|
+
require 'tfso/errors'
|
4
5
|
require 'tfso/authentication'
|
5
6
|
require 'tfso/client'
|
6
7
|
require 'tfso/company'
|
7
8
|
require 'tfso/invoice'
|
8
9
|
require 'tfso/payment'
|
9
|
-
require 'tfso/product'
|
10
|
+
require 'tfso/product'
|
11
|
+
require 'tfso/person'
|
data/lib/tfso/authentication.rb
CHANGED
@@ -14,17 +14,19 @@ module TFSO
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def authenticated?
|
17
|
-
response = savon_client.call(:has_session, cookies: @cookies
|
17
|
+
response = savon_client.call(:has_session, cookies: @cookies)
|
18
|
+
raise Errors::Authentication, 'Not authenticated' if !response.body[:has_session_response][:has_session_result]
|
18
19
|
response.body[:has_session_response][:has_session_result]
|
19
20
|
end
|
20
21
|
|
21
22
|
def authenticate(username, password, identity_id = nil)
|
22
|
-
response = savon_client.call(:login, message: { credential: {Username: username, Password: password, IdentityId: identity_id, ApplicationId: application_id}
|
23
|
+
response = savon_client.call(:login, message: { credential: {Username: username, Password: password, IdentityId: identity_id, ApplicationId: application_id}})
|
24
|
+
raise Errors::Authentication, 'Incorrect credentials' if response.body[:login_response][:login_result].blank?
|
23
25
|
self.session_id = response.body[:login_response][:login_result]
|
24
26
|
end
|
25
27
|
|
26
28
|
def identities
|
27
|
-
response = savon_client.call(:get_identities, cookies: @cookies
|
29
|
+
response = savon_client.call(:get_identities, cookies: @cookies)
|
28
30
|
list = response.body[:get_identities_response][:get_identities_result][:identity]
|
29
31
|
if list.is_a?(Hash)
|
30
32
|
[list]
|
@@ -39,7 +41,7 @@ module TFSO
|
|
39
41
|
end
|
40
42
|
|
41
43
|
def identity_id=(identity_id)
|
42
|
-
|
44
|
+
savon_client.call(:set_identity_by_id, message: {identityId: identity_id}, cookies: @cookies)
|
43
45
|
@identity_id = identity_id
|
44
46
|
end
|
45
47
|
|
data/lib/tfso/client.rb
CHANGED
@@ -6,12 +6,13 @@ module TFSO
|
|
6
6
|
URL = 'https://api.24sevenoffice.com/Client/V001/ClientService.asmx?WSDL'
|
7
7
|
|
8
8
|
def initialize(auth)
|
9
|
+
ensure_authenticated(auth)
|
9
10
|
self.session_id = auth.session_id
|
10
11
|
intialize_savon_client
|
11
12
|
end
|
12
13
|
|
13
14
|
def type_groups(module_type)
|
14
|
-
response = savon_client.call(:get_type_group_list, message: {module_type: module_type
|
15
|
+
response = savon_client.call(:get_type_group_list, message: {module_type: module_type}, cookies: @cookies)
|
15
16
|
response.body[:get_type_group_list_response][:get_type_group_list_result]
|
16
17
|
end
|
17
18
|
|
data/lib/tfso/company.rb
CHANGED
@@ -6,12 +6,13 @@ module TFSO
|
|
6
6
|
URL = 'https://api.24sevenoffice.com/CRM/Company/V001/CompanyService.asmx?wsdl'
|
7
7
|
|
8
8
|
def initialize(auth)
|
9
|
+
ensure_authenticated(auth)
|
9
10
|
self.session_id = auth.session_id
|
10
11
|
intialize_savon_client
|
11
12
|
end
|
12
13
|
|
13
14
|
def find(search_params)
|
14
|
-
response = savon_client.call(:get_companies, message: {searchParams: search_params, returnProperties: {string: ['Id', 'OrganizationNumber', 'NickName', 'Country', 'Addresses', 'EmailAddresses', 'PhoneNumbers', 'InvoiceLanguage', 'TypeGroup', 'DistributionMethod', 'Currency']
|
15
|
+
response = savon_client.call(:get_companies, message: {searchParams: search_params, returnProperties: {string: ['Id', 'OrganizationNumber', 'NickName', 'Country', 'Addresses', 'EmailAddresses', 'PhoneNumbers', 'InvoiceLanguage', 'TypeGroup', 'DistributionMethod', 'Currency']}}, cookies: @cookies)
|
15
16
|
result = response.body[:get_companies_response][:get_companies_result]
|
16
17
|
if result
|
17
18
|
if result[:company].class == Hash
|
@@ -35,7 +36,7 @@ module TFSO
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def create(company_info)
|
38
|
-
response = savon_client.call(:save_companies, message: {companies: [{Company: company_info}]
|
39
|
+
response = savon_client.call(:save_companies, message: {companies: [{Company: company_info}]}, cookies: @cookies)
|
39
40
|
result = response.body[:save_companies_response][:save_companies_result]
|
40
41
|
if result
|
41
42
|
if result[:company].class == Hash
|
@@ -109,13 +110,13 @@ module TFSO
|
|
109
110
|
company.delete(:billing_address)
|
110
111
|
end
|
111
112
|
if company[:tfso]
|
112
|
-
company[:tfso].keys.each{|k| company[k] = company[:tfso].delete(k)
|
113
|
+
company[:tfso].keys.each{|k| company[k] = company[:tfso].delete(k)}
|
113
114
|
company.delete(:tfso)
|
114
115
|
end
|
115
116
|
|
116
117
|
mappings = {:name => :Name, :nickname => :NickName, :gov_no => :OrganizationNumber, :country_code => :Country}
|
117
118
|
|
118
|
-
company.keys.each {
|
119
|
+
company.keys.each {|k| company[ mappings[k] ] = company.delete(k) if mappings[k]}
|
119
120
|
company
|
120
121
|
end
|
121
122
|
|
data/lib/tfso/errors.rb
ADDED
data/lib/tfso/helpers.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
module TFSO
|
2
2
|
|
3
3
|
module Helpers
|
4
|
+
|
4
5
|
def intialize_savon_client
|
5
6
|
@savon_client = Savon.client(wsdl: self.class::URL, convert_request_keys_to: :none)
|
6
|
-
if defined?(Rails) && Rails.env.development?
|
7
|
+
if ENV['RACK_ENV'] == 'test' || defined?(Rails) && Rails.env.development?
|
7
8
|
@savon_client.globals.proxy('http://localhost:8080')
|
8
9
|
@savon_client.globals.ssl_verify_mode(:none)
|
9
10
|
end
|
10
11
|
@savon_client.globals.unwrap(true)
|
11
12
|
end
|
12
13
|
|
14
|
+
def ensure_authenticated(auth)
|
15
|
+
auth.authenticated?
|
16
|
+
end
|
17
|
+
|
13
18
|
def savon_client
|
14
19
|
@savon_client
|
15
20
|
end
|
data/lib/tfso/invoice.rb
CHANGED
@@ -6,6 +6,7 @@ module TFSO
|
|
6
6
|
URL = 'https://api.24sevenoffice.com/Economy/InvoiceOrder/V001/InvoiceService.asmx?wsdl'
|
7
7
|
|
8
8
|
def initialize(auth)
|
9
|
+
ensure_authenticated(auth)
|
9
10
|
self.session_id = auth.session_id
|
10
11
|
intialize_savon_client
|
11
12
|
end
|
@@ -41,7 +42,7 @@ module TFSO
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def create(order_attributes)
|
44
|
-
response = savon_client.call(:save_invoices, message: {invoices: [{InvoiceOrder: order_attributes
|
45
|
+
response = savon_client.call(:save_invoices, message: {invoices: [{InvoiceOrder: order_attributes}] }, cookies: @cookies)
|
45
46
|
response.body[:save_invoices_response][:save_invoices_result][:invoice_order]
|
46
47
|
end
|
47
48
|
|
@@ -92,14 +93,22 @@ module TFSO
|
|
92
93
|
if items.any?
|
93
94
|
invoiceRows = []
|
94
95
|
items.each {|item|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
if item[:type] == :text
|
97
|
+
invoiceRows << {:InvoiceRow => {
|
98
|
+
Type: 'Text',
|
99
|
+
Name: item[:name]
|
100
|
+
}}
|
101
|
+
else
|
102
|
+
invoiceRows << {:InvoiceRow => {
|
103
|
+
Type: 'Normal',
|
104
|
+
ProductId: item[:product_id],
|
105
|
+
Name: item[:name],
|
106
|
+
Price: item[:price].to_f,
|
107
|
+
Quantity: item[:quantity].to_f
|
108
|
+
}}
|
109
|
+
end
|
101
110
|
}
|
102
|
-
invoice_info[:InvoiceRows] =
|
111
|
+
invoice_info[:InvoiceRows] = invoiceRows
|
103
112
|
end
|
104
113
|
invoice_info
|
105
114
|
end
|
data/lib/tfso/payment.rb
CHANGED
@@ -6,12 +6,13 @@ module TFSO
|
|
6
6
|
URL = 'https://api.24sevenoffice.com/Economy/InvoiceOrder/V001/PaymentService.asmx?WSDL'
|
7
7
|
|
8
8
|
def initialize(auth)
|
9
|
+
ensure_authenticated(auth)
|
9
10
|
self.session_id = auth.session_id
|
10
11
|
intialize_savon_client
|
11
12
|
end
|
12
13
|
|
13
14
|
def create(payment_info)
|
14
|
-
response = savon_client.call(:register_invoice_payment, message: {payment: payment_info
|
15
|
+
response = savon_client.call(:register_invoice_payment, message: {payment: payment_info}, cookies: @cookies)
|
15
16
|
response.body[:register_invoice_payment_response][:register_invoice_payment_result]
|
16
17
|
end
|
17
18
|
|
data/lib/tfso/person.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module TFSO
|
2
|
+
class Person
|
3
|
+
|
4
|
+
include TFSO::Helpers
|
5
|
+
|
6
|
+
URL = 'https://webservices.24sevenoffice.com/CRM/Contact/PersonService.asmx?WSDL'
|
7
|
+
|
8
|
+
def initialize(auth)
|
9
|
+
ensure_authenticated(auth)
|
10
|
+
self.session_id = auth.session_id
|
11
|
+
intialize_savon_client
|
12
|
+
end
|
13
|
+
|
14
|
+
def find(search_params={})
|
15
|
+
response = savon_client.call(:get_persons, message: {personSearch: search_params}, cookies: @cookies)
|
16
|
+
result = response.body[:get_persons_response][:get_persons_result]
|
17
|
+
if result
|
18
|
+
if result[:person_item].class == Hash
|
19
|
+
[result[:person_item]]
|
20
|
+
else
|
21
|
+
result[:person_item]
|
22
|
+
end
|
23
|
+
else
|
24
|
+
[]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def create(person_info)
|
29
|
+
response = savon_client.call(:save_person, message: {personItem: person_info}, cookies: @cookies)
|
30
|
+
result = response.body[:save_person_response][:save_person_result]
|
31
|
+
if result
|
32
|
+
if result.class == Hash
|
33
|
+
if result[:api_exception]
|
34
|
+
raise "Error when saving tfso person"
|
35
|
+
else
|
36
|
+
result
|
37
|
+
end
|
38
|
+
else
|
39
|
+
result
|
40
|
+
end
|
41
|
+
else
|
42
|
+
false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
data/lib/tfso/product.rb
CHANGED
@@ -6,6 +6,7 @@ module TFSO
|
|
6
6
|
URL = 'https://api.24sevenoffice.com/Logistics/Product/V001/ProductService.asmx?WSDL'
|
7
7
|
|
8
8
|
def initialize(auth)
|
9
|
+
ensure_authenticated(auth)
|
9
10
|
self.session_id = auth.session_id
|
10
11
|
intialize_savon_client
|
11
12
|
end
|
@@ -30,6 +31,5 @@ module TFSO
|
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
34
|
end
|
35
35
|
end
|
data/lib/tfso/version.rb
CHANGED
data/tfso.gemspec
CHANGED
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_dependency "savon"
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler"
|
26
|
-
spec.add_development_dependency "rake"
|
27
|
-
spec.add_development_dependency "minitest"
|
25
|
+
spec.add_development_dependency "bundler"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "minitest"
|
28
28
|
spec.add_development_dependency "dotenv"
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tfso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Espen Antonsen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|
@@ -28,44 +28,44 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: dotenv
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email:
|
85
85
|
- espen@inspired.no
|
86
86
|
executables: []
|
@@ -99,9 +99,11 @@ files:
|
|
99
99
|
- lib/tfso/authentication.rb
|
100
100
|
- lib/tfso/client.rb
|
101
101
|
- lib/tfso/company.rb
|
102
|
+
- lib/tfso/errors.rb
|
102
103
|
- lib/tfso/helpers.rb
|
103
104
|
- lib/tfso/invoice.rb
|
104
105
|
- lib/tfso/payment.rb
|
106
|
+
- lib/tfso/person.rb
|
105
107
|
- lib/tfso/product.rb
|
106
108
|
- lib/tfso/version.rb
|
107
109
|
- tfso.gemspec
|
@@ -109,7 +111,7 @@ homepage: https://github.com/espen/tfso
|
|
109
111
|
licenses:
|
110
112
|
- MIT
|
111
113
|
metadata: {}
|
112
|
-
post_install_message:
|
114
|
+
post_install_message:
|
113
115
|
rdoc_options: []
|
114
116
|
require_paths:
|
115
117
|
- lib
|
@@ -124,8 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
126
|
- !ruby/object:Gem::Version
|
125
127
|
version: '0'
|
126
128
|
requirements: []
|
127
|
-
rubygems_version: 3.
|
128
|
-
signing_key:
|
129
|
+
rubygems_version: 3.2.17
|
130
|
+
signing_key:
|
129
131
|
specification_version: 4
|
130
132
|
summary: Ruby API Wrapper for 24SevenOffice.
|
131
133
|
test_files: []
|