dipps-client 0.3.0 → 0.4.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 +4 -4
- data/lib/dipps/client/error.rb +6 -0
- data/lib/dipps/client/version.rb +1 -1
- data/lib/dipps/client.rb +27 -12
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32e06a0867bf5dba987bd485a33aef46e2503eb7dc981c2dcef85da07a2d0401
|
4
|
+
data.tar.gz: b575a94100e0823bc661a2174a9676b0a25a62d3c4f5aeed218b2c86477aacf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74c9434a63de1071b035ff973a6a2494a4563dedefe3b20840183f5cff4a61784678c0e7be25f17c16a1e666785372c2d8597a4d3d28e4149c52fdffe8879613
|
7
|
+
data.tar.gz: 98b6321edc89213400bbb05e20f25805005ad1e041279d4685bbe43113270df73f8cf52b5d464e90cf29083851c6993f77e49455b6b34e341f6c76422b5db6b9
|
data/lib/dipps/client/version.rb
CHANGED
data/lib/dipps/client.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'client/version'
|
4
4
|
require_relative 'client/configuration'
|
5
|
+
require_relative 'client/error'
|
5
6
|
|
6
7
|
module Dipps
|
7
8
|
module Client
|
@@ -22,43 +23,57 @@ module Dipps
|
|
22
23
|
@configuration ||= Dipps::Client::Configuration.new
|
23
24
|
end
|
24
25
|
|
26
|
+
def perform_query(query:, result_field:, variables: {})
|
27
|
+
result = GraphqlClient.query(query, variables: variables)
|
28
|
+
|
29
|
+
if result.errors.any?
|
30
|
+
raise(Dipps::Client::Error, result.errors.details.inspect)
|
31
|
+
end
|
32
|
+
|
33
|
+
result.data.to_h.fetch(result_field)
|
34
|
+
end
|
35
|
+
|
25
36
|
def create_own_invoice(freelance_profile_id:, attributes:)
|
26
|
-
|
27
|
-
Dipps::Client::Queries::CreateOwnInvoice,
|
37
|
+
perform_query(
|
38
|
+
query: Dipps::Client::Queries::CreateOwnInvoice,
|
39
|
+
result_field: 'createOwnInvoice',
|
28
40
|
variables: {
|
29
41
|
freelance_profile_id: freelance_profile_id,
|
30
42
|
attributes: attributes
|
31
43
|
}
|
32
|
-
)
|
44
|
+
)
|
33
45
|
end
|
34
46
|
|
35
47
|
def clients(org_number: nil, email: nil)
|
36
|
-
|
37
|
-
Dipps::Client::Queries::Clients,
|
48
|
+
perform_query(
|
49
|
+
query: Dipps::Client::Queries::Clients,
|
50
|
+
result_field: 'clients',
|
38
51
|
variables: {
|
39
52
|
orgNumber: org_number,
|
40
53
|
email: email
|
41
54
|
}
|
42
|
-
)
|
55
|
+
)
|
43
56
|
end
|
44
57
|
|
45
58
|
def create_client(attributes:)
|
46
|
-
|
47
|
-
Dipps::Client::Queries::CreateClient,
|
59
|
+
perform_query(
|
60
|
+
query: Dipps::Client::Queries::CreateClient,
|
61
|
+
result_field: 'createClient',
|
48
62
|
variables: {
|
49
63
|
attributes: attributes
|
50
64
|
}
|
51
|
-
)
|
65
|
+
)
|
52
66
|
end
|
53
67
|
|
54
68
|
def update_client(id:, attributes:)
|
55
|
-
|
56
|
-
Dipps::Client::Queries::UpdateClient,
|
69
|
+
perform_query(
|
70
|
+
query: Dipps::Client::Queries::UpdateClient,
|
71
|
+
result_field: 'updateClient',
|
57
72
|
variables: {
|
58
73
|
id: id,
|
59
74
|
attributes: attributes
|
60
75
|
}
|
61
|
-
)
|
76
|
+
)
|
62
77
|
end
|
63
78
|
end
|
64
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dipps-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Kuznietsov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql-client
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- dipps-client.gemspec
|
57
57
|
- lib/dipps/client.rb
|
58
58
|
- lib/dipps/client/configuration.rb
|
59
|
+
- lib/dipps/client/error.rb
|
59
60
|
- lib/dipps/client/graphql_client.rb
|
60
61
|
- lib/dipps/client/queries.rb
|
61
62
|
- lib/dipps/client/queries/clients.rb
|