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 +4 -4
- data/.github/workflows/ruby-app.yml +25 -0
- data/README.md +6 -8
- data/lib/payload/arm/request.rb +2 -4
- data/lib/payload/objects.rb +4 -0
- data/lib/payload/version.rb +1 -1
- data/spec/payload/arm/request_spec.rb +45 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34f564177aca2508a3ab7864c3c86b2750fbe7b6d678bcf821d4f802da7d59b5
|
4
|
+
data.tar.gz: 626a0ecbdfff120ca85a8e8bef68af08fdfe7627826baeb6f88bfe10e1818197
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
```
|
26
|
-
|
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
|
-
```
|
35
|
-
|
36
|
-
|
32
|
+
```ruby
|
33
|
+
require 'payload'
|
34
|
+
Payload.api_key = 'secret_key_3bW9JMZtPVDOfFNzwRdfE'
|
37
35
|
```
|
38
36
|
|
39
37
|
### Creating an Object
|
data/lib/payload/arm/request.rb
CHANGED
data/lib/payload/objects.rb
CHANGED
data/lib/payload/version.rb
CHANGED
@@ -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
|
+
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-
|
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
|