payload-api 0.6.1 → 0.6.2

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: a6364ada87b188e97370c985aaee315c1abe7149162d0bfe1a1feca21407e416
4
- data.tar.gz: 0ba29b0d267e6dbe078c0ffe8a20ac915cfebb515e9ac20f6d7f8697160a45d5
3
+ metadata.gz: 3ed53d5dcc3451ce907cbc5a4c28b294abd0c7819a3b1d20505e077378f1bfb5
4
+ data.tar.gz: 27d17e508ae166fce7dbad51d86ffdf6986c6c0a11624e4c4609b1733895ea03
5
5
  SHA512:
6
- metadata.gz: d6e5b2ebca0650bc0358a0d8883681363a519795ffa49349fb936f821175d9d173f45ad49c86553ac701f3a284bfd48f8cdf901831fa7b559a7dc13c0f0adb07
7
- data.tar.gz: 18634323e7c0221562430f79fc68638f2db08f2ee9caea5bb2b3c7b3f577aa2d8b70627ad17af9e3b72d2f9ed802ef211b69a2bc60566036b8922f3bb2b35b5b
6
+ metadata.gz: ca2f23bb36bdb05dfadf24fc931e55986e9f856c393685a5e07540e9325b05fb33eda290dc2cd2c1910e1cc0c312ec9bfc99a7dab598bd6260f8b6a04d2b6e8e
7
+ data.tar.gz: 90166f672175b2cddc3a3b8be0450f028bcc1da8060d519775cce6f462ea08b613f70a6811bfcc69786a0fdfa216d1cd999f964ff36cafe9b69b4ea9632cee0c
@@ -152,6 +152,10 @@ module Payload
152
152
 
153
153
  data = { object: 'list', values: data }
154
154
  else
155
+ if data.kind_of?(ARMObject)
156
+ @cls = data.class
157
+ data = data.data
158
+ end
155
159
  if @cls.poly
156
160
  data = data.merge(@cls.poly)
157
161
  end
@@ -1,3 +1,3 @@
1
1
  module Payload
2
- VERSION = '0.6.1'
3
- end
2
+ VERSION = '0.6.2'
3
+ end
@@ -299,6 +299,57 @@ RSpec.describe Payload::ARMRequest do
299
299
  expect(customers[2].session).to eq(instance.instance_variable_get(:@session))
300
300
  end
301
301
  end
302
+
303
+ context "when the user creates a single ARMObject via Session#create" do
304
+ it "executes the appropriate request and returns the appropriate object" do
305
+
306
+ $test_access_token = 'tok_' + rand(900000..999999).to_s
307
+ $test_refresh_token = 'ref_' + rand(900000..999999).to_s
308
+
309
+ Payload::api_key = 'test_key'
310
+ pl = Payload::Session.new('test_key', 'https://api.payload.com')
311
+
312
+ expect_any_instance_of(Payload::ARMRequest).to receive(:_execute_request) do |_req, http, request|
313
+ expect(request.method).to eq("POST")
314
+ expect(http.address).to eq("api.payload.com")
315
+ expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
316
+ expect(request.path).to eq("/oauth/token?")
317
+ expect(request.body).to eq("{\"code\":\"auth_code_123\",\"grant_type\":\"authorization_code\",\"client_id\":\"org_abc\",\"client_secret\":\"secret_key_xyz\"}")
318
+
319
+ class MockResponse
320
+ def initialize
321
+ end
322
+
323
+ def code
324
+ '200'
325
+ end
326
+
327
+ def body
328
+ '{
329
+ "object": "oauth_token",
330
+ "access_token": "' + $test_access_token + '",
331
+ "refresh_token": "' + $test_refresh_token + '"
332
+ }'
333
+ end
334
+ end
335
+
336
+ MockResponse.new
337
+ end
338
+
339
+ oauth_token = pl.create(Payload::OAuthToken.new({
340
+ code: 'auth_code_123',
341
+ grant_type: 'authorization_code',
342
+ client_id: 'org_abc',
343
+ client_secret: 'secret_key_xyz'
344
+ }))
345
+
346
+ expect(oauth_token).to be_a(Payload::OAuthToken)
347
+ expect(oauth_token.object).to eq("oauth_token")
348
+ expect(oauth_token.access_token).to eq($test_access_token)
349
+ expect(oauth_token.refresh_token).to eq($test_refresh_token)
350
+ expect(oauth_token.session).to eq(pl)
351
+ end
352
+ end
302
353
  end
303
354
 
304
355
  describe "#get" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payload-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Payload
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-10 00:00:00.000000000 Z
11
+ date: 2026-02-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple library to interface with the Payload API. See https://docs.payload.com
14
14
  for details.