purple-client 0.1.7.4 → 0.1.7.6
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/README.md +31 -1
- data/lib/purple/responses/body.rb +6 -0
- data/lib/purple/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: 2f57285cc0997c1352f58c090079dc236e52ecf08c040b1a2d68b2e44824b344
|
4
|
+
data.tar.gz: '094e99048e10af59faabec36d819ec1b075a65bfb47eaebd422ddee9dd216d84'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2a8c339a3dfa90dc44444b421b13c819152e3f0c9ce3a0bede32604c9b5bf00ea9068bfff074bc84c8165093167f2c1bb8756ba0fbb059a0e8cb03ebc63705c
|
7
|
+
data.tar.gz: 8ae3c368e5130486f5c4d466d9232095da167f957134ef2192798fc446b79f69ceb635c8bd1a14f91b745a8f0cdf6bab7384d9e71b46e9bdd17c30868da8bd5a
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Purple
|
1
|
+
# Purple Client
|
2
2
|
|
3
3
|
Purple::Client is a small DSL that helps you describe HTTP APIs. You define a domain, paths, and response structures, and the library generates handy methods for interacting with your service.
|
4
4
|
|
@@ -59,6 +59,36 @@ end
|
|
59
59
|
JobsClient.job(123)
|
60
60
|
```
|
61
61
|
|
62
|
+
### Simple POST request
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
class Amocrm::Client < Purple::Client
|
66
|
+
domain 'https://www.amocrm.ru'
|
67
|
+
|
68
|
+
path :oauth2 do
|
69
|
+
path :access_token, method: :post do
|
70
|
+
root_method :access_token
|
71
|
+
|
72
|
+
params do |client_id:, client_secret:, redirect_uri:, code:, grant_type: :authorization_code|
|
73
|
+
{ client_id:, client_secret:, redirect_uri:, code:, grant_type: }
|
74
|
+
end
|
75
|
+
|
76
|
+
response :ok do
|
77
|
+
body(
|
78
|
+
token_type: String,
|
79
|
+
expires_in: Integer,
|
80
|
+
server_time: Integer,
|
81
|
+
access_token: String,
|
82
|
+
refresh_token: String
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
response :bad_request
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
62
92
|
### Using authorization
|
63
93
|
|
64
94
|
```ruby
|
@@ -82,6 +82,10 @@ class Purple::Responses::Body
|
|
82
82
|
end
|
83
83
|
elsif value.is_a?(Array)
|
84
84
|
object[key].each do |item|
|
85
|
+
if value[0].is_a?(Symbol)
|
86
|
+
raise "Body structure definition error in key '#{key}' of structure #{substructure}."
|
87
|
+
end
|
88
|
+
|
85
89
|
check_structure!(item, value[0])
|
86
90
|
end
|
87
91
|
else
|
@@ -96,6 +100,8 @@ class Purple::Responses::Body
|
|
96
100
|
end
|
97
101
|
|
98
102
|
def check_type!(object, key, expected_type)
|
103
|
+
return if key.in?([:optional, :allow_blank])
|
104
|
+
|
99
105
|
unless object.key?(key)
|
100
106
|
raise BodyStructureMismatchError.new(key, expected_type, object[key], object),
|
101
107
|
"Missing field '#{key}' in response body. Body: #{object}"
|
data/lib/purple/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purple-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.7.
|
4
|
+
version: 0.1.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-initializer
|