payload-api 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5783328f0a31aea836478841802815c16aaef86b22ff101c698b61603f1437cd
4
- data.tar.gz: 4e606c81caaec76f7410e7e29c55c77261ae28b2c5b69c9191b62eb297a82d3f
3
+ metadata.gz: 34f564177aca2508a3ab7864c3c86b2750fbe7b6d678bcf821d4f802da7d59b5
4
+ data.tar.gz: 626a0ecbdfff120ca85a8e8bef68af08fdfe7627826baeb6f88bfe10e1818197
5
5
  SHA512:
6
- metadata.gz: 5aa4c8bbc4bb6a15feb4473378289b1f9d7c7ea510cca774a77cce4fcc3cd30a7aece820aaabfa5f24c54dd6fc3f09bf9f146955f5e1b05975947f04d1870fc8
7
- data.tar.gz: 5e7ded315bac9487390cdaa23b18a59770f5f1b3eb1896f99d6a33e270bb3c0906b40e0df22dc58b37c45000564bb78c9def03ff36ecdac909c0667492d83fc7
6
+ metadata.gz: bbdfbe194bc9a878426bc74cd6c59107852a557a5a2fc1c9c5353bcca935ba189e64fc5a88d4a13076eb6ab104b6d57f337a7326fa9be58ab1974d595ada2a87
7
+ data.tar.gz: 5b9d5a44b34ecd605e94e3c6910b9f2dcef895f84ac29987bfd84234490befe616904322e2c3859ef4e062ccd1d5d11945bb33822dc8e58395576cd408fc2b3e
@@ -0,0 +1,25 @@
1
+ name: RSpec Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ rspec:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout code
15
+ uses: actions/checkout@v2
16
+
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: 3.0.1
21
+
22
+ - name: Run RSpec tests
23
+ run: |
24
+ gem install rspec
25
+ rspec spec
@@ -10,16 +10,11 @@ module Payload
10
10
 
11
11
  def initialize(cls=nil)
12
12
  @cls = cls
13
- @selected_fields = ''
14
13
  @filters = {}
15
14
  end
16
15
 
17
16
  def select(*args, **data)
18
- if @cls.poly
19
- data = data.merge(@cls.poly)
20
- end
21
-
22
- @selected_fields = args.join(',')
17
+ @filters['fields'] = args.map {|a| a.strip }.join(',')
23
18
 
24
19
  return self
25
20
  end
@@ -87,14 +82,6 @@ module Payload
87
82
  end
88
83
 
89
84
  def _request(method, id: nil, json: nil)
90
-
91
- # Update @filters['fields'] with @selected_fields
92
- fields_list = []
93
- fields_list << @filters['fields'] if @filters['fields'] && !@filters['fields'].empty?
94
- fields_list << @selected_fields if @selected_fields && !@selected_fields.empty?
95
- @filters['fields'] = fields_list.join(',') if fields_list.any?
96
- @filters['fields'] ||= '*'
97
-
98
85
  if @cls.spec.key?("endpoint")
99
86
  endpoint = @cls.spec["endpoint"]
100
87
  else
@@ -82,4 +82,8 @@ module Payload
82
82
  class Webhook < ARMObject
83
83
  @spec = { 'object' => 'webhook' }
84
84
  end
85
+
86
+ class PaymentLink < ARMObject
87
+ @spec = { 'object' => 'payment_link' }
88
+ end
85
89
  end
@@ -1,3 +1,3 @@
1
1
  module Payload
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
@@ -0,0 +1,45 @@
1
+ require "payload"
2
+ require "payload/arm/object"
3
+
4
+
5
+ RSpec.describe Payload::ARMRequest do
6
+
7
+ describe "#select" do
8
+
9
+ let(:instance) { described_class.new }
10
+
11
+ context "when the user selects custom fields" do
12
+ it "merges the given data with the class's polymorphic association" do
13
+ instance.select(' name', 'age ')
14
+ expect(instance.instance_variable_get(:@filters)).to eq({ "fields" => "name,age" })
15
+ instance.select('count(id)', 'sum(amount)')
16
+ expect(instance.instance_variable_get(:@filters)).to eq({ "fields" => "count(id),sum(amount)" })
17
+ end
18
+ end
19
+ end
20
+
21
+ describe "#filter_by" do
22
+
23
+ let(:instance) do
24
+ class TestObject < Payload::ARMObject
25
+ @poly = { "type" => "test" }
26
+ end
27
+ Payload::ARMRequest.new(TestObject)
28
+ end
29
+
30
+ context "when the class does not have a polymorphic association" do
31
+ it "sets the given data as filters" do
32
+ instance.filter_by(name: "John", age: 30)
33
+ expect(instance.instance_variable_get(:@filters)).to eq({name: "John", age: 30, "type" => "test"})
34
+ end
35
+ end
36
+
37
+ context "when called multiple times" do
38
+ it "merges all the given data into a single hash" do
39
+ instance.filter_by(name: "John", city: "San Francisco")
40
+ instance.filter_by(age: ['<30', '>20'])
41
+ expect(instance.instance_variable_get(:@filters)).to eq({name: "John", age: ['<30', '>20'], city: "San Francisco", "type" => "test"})
42
+ end
43
+ end
44
+ end
45
+ end
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.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Payload
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-13 00:00:00.000000000 Z
11
+ date: 2023-05-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple library to interface with the Payload API. See https://docs.payload.co
14
14
  for details.
@@ -17,6 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".github/workflows/ruby-app.yml"
20
21
  - LICENSE
21
22
  - README.md
22
23
  - lib/payload.rb
@@ -27,6 +28,7 @@ files:
27
28
  - lib/payload/utils.rb
28
29
  - lib/payload/version.rb
29
30
  - payload.gemspec
31
+ - spec/payload/arm/request_spec.rb
30
32
  homepage: https://docs.payload.co
31
33
  licenses:
32
34
  - MIT