purple-client 0.1.6 → 0.1.7.1

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: 3d7c34549894887ef34dc72c7f18f33f3f5304a0a569c031fccb835d09e68bf7
4
- data.tar.gz: 40590441cf6fd76570c27f1afe5fbce885d35d2384e34b5d6e798580fbddeacc
3
+ metadata.gz: 39f3cee0069620b8f540e7103eb4aa27fa0b7384a0b473c586dde47f6cebd62d
4
+ data.tar.gz: fe5c9ac61f1795b3994124c53ce1c5a31657a6e429e42e60c016b1c32a1909df
5
5
  SHA512:
6
- metadata.gz: e85083d17e33a74e9ecbc1ea1c7bee1977fe15ef942baafb6f9d751be44d107b5eede568d41868b6a571433dbe061f96bce9c6f9c9788ccf6589b24e456a9bd8
7
- data.tar.gz: 83b324460273f9edc99d8e95e0c914bc9944ce887938fe10ec404a6e8efe111222b93d48cfbee871017fbc5e082bc75a05026c4d21cce45123ca27f17ac5039a
6
+ metadata.gz: 3bf2ea0e3cd4aca1b327ad57da1711775a1bb14208163f41a8d6632232c1e45b5abba8a70c2b2953acd10288f5ad111ac83bf315e5056496801c8942d4163636
7
+ data.tar.gz: 5e544d9b54f7938fdca2f71ae58a6ce9e11815eae8d545511bab5afc7e5a4e93edb4dbdc30da572dd57e4a8fc9e412b8001533f303ebed7dfb667185c055fa64
data/README.md CHANGED
@@ -151,6 +151,29 @@ extracted from the call and passed to your callback. In the example above the
151
151
  available inside the callback so you can associate the stored event with a
152
152
  record of your choice.
153
153
 
154
+ ### Boolean response types
155
+
156
+ If you have boolean types `true` or `false` in your response, use
157
+ `Purple::Boolean` in the response configuration.
158
+
159
+ ```ruby
160
+ class AccountsClient < Purple::Client
161
+ domain 'https://api.example.com'
162
+
163
+ path :accounts do
164
+ response :ok do
165
+ body(
166
+ last_name: String,
167
+ first_name: String,
168
+ is_creator: Purple::Boolean,
169
+ is_premium: Purple::Boolean,
170
+ )
171
+ end
172
+ root_method :accounts
173
+ end
174
+ end
175
+ ```
176
+
154
177
  ## Development
155
178
 
156
179
  After checking out the repo, run `bin/setup` to install dependencies. Then run
data/lib/purple/client.rb CHANGED
@@ -65,9 +65,8 @@ module Purple
65
65
 
66
66
  define_singleton_method method_name do |*call_args, **kw_args, &block|
67
67
  if current_path.is_param
68
- value = kw_args[current_path.name] || call_args.first
68
+ value = call_args.first
69
69
  current_path.with(value)
70
- kw_args[current_path.name] = value
71
70
  end
72
71
 
73
72
  callback_arguments = additional_callback_arguments.map do |arg|
data/lib/purple/path.rb CHANGED
@@ -74,6 +74,12 @@ module Purple
74
74
  connection.get(url, params)
75
75
  when :post
76
76
  connection.post(url, params.to_json)
77
+ when :put
78
+ connection.put(url, params.to_json)
79
+ when :delete
80
+ connection.delete(url, params)
81
+ when :patch
82
+ connection.patch(url, params.to_json)
77
83
  end
78
84
 
79
85
  resp_structure = responses.find { |resp| resp.status_code == response.status }
@@ -13,6 +13,7 @@ class Purple::Response
13
13
  ok: 200,
14
14
  bad_request: 400,
15
15
  unauthorized: 401,
16
+ unprocessable_entity: 422,
16
17
  forbidden: 403,
17
18
  not_found: 404,
18
19
  too_many_requests: 429,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Purple
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: purple-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov