payload-api 0.2.4 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbb1f9ed364eb3e8d721aa2e52e3998097e764c5efdb650b7c1ab840b792197d
4
- data.tar.gz: 17e0e956231c7ae5ccfb0c63ca1a50061d4ed1812b7c8871c3d54f38e7254a05
3
+ metadata.gz: 34f564177aca2508a3ab7864c3c86b2750fbe7b6d678bcf821d4f802da7d59b5
4
+ data.tar.gz: 626a0ecbdfff120ca85a8e8bef68af08fdfe7627826baeb6f88bfe10e1818197
5
5
  SHA512:
6
- metadata.gz: 32dc9421316afd86f9df392613d2f6c4b5ef793c0a82e5256718bf3740408ec3b055f3916d8e9a5c06d792eb5cf589338452dec6b46ad5bf0e14ab15ce8ac81b
7
- data.tar.gz: cd79ebdffa7156488217896c5b6ae37379f9efbe9781cfcdfcd6690ae9acd21eb70c4debabd48bf0e99c45a704303df5702717c510dcfe2c6ffd672efabeed55
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
data/README.md CHANGED
@@ -18,12 +18,10 @@ gem install payload
18
18
 
19
19
  ## Get Started
20
20
 
21
- Once you've installed the Payload Python library to your environment,
22
- import the `payload` module to get started. **Note:** We recommend
23
- using the shorthand name of `pl` when importing.
21
+ Once Payload has been added to your Gemfile and installed, use `require` as shown below to import it into your project.
24
22
 
25
- ```python
26
- import payload as pl
23
+ ```ruby
24
+ require 'payload'
27
25
  ```
28
26
 
29
27
  ### API Authentication
@@ -31,9 +29,9 @@ import payload as pl
31
29
  To authenticate with the Payload API, you'll need a live or test API key. API
32
30
  keys are accessible from within the Payload dashboard.
33
31
 
34
- ```python
35
- import payload as pl
36
- pl.api_key = 'secret_key_3bW9JMZtPVDOfFNzwRdfE'
32
+ ```ruby
33
+ require 'payload'
34
+ Payload.api_key = 'secret_key_3bW9JMZtPVDOfFNzwRdfE'
37
35
  ```
38
36
 
39
37
  ### Creating an Object
@@ -14,10 +14,8 @@ module Payload
14
14
  end
15
15
 
16
16
  def select(*args, **data)
17
- if @cls.poly
18
- data = data.merge(@cls.poly)
19
- end
20
-
17
+ @filters['fields'] = args.map {|a| a.strip }.join(',')
18
+
21
19
  return self
22
20
  end
23
21
 
@@ -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.4'
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.4
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-03-27 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