payload-api 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -9
- data/lib/payload/arm/request.rb +20 -2
- data/lib/payload/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5783328f0a31aea836478841802815c16aaef86b22ff101c698b61603f1437cd
|
4
|
+
data.tar.gz: 4e606c81caaec76f7410e7e29c55c77261ae28b2c5b69c9191b62eb297a82d3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5aa4c8bbc4bb6a15feb4473378289b1f9d7c7ea510cca774a77cce4fcc3cd30a7aece820aaabfa5f24c54dd6fc3f09bf9f146955f5e1b05975947f04d1870fc8
|
7
|
+
data.tar.gz: 5e7ded315bac9487390cdaa23b18a59770f5f1b3eb1896f99d6a33e270bb3c0906b40e0df22dc58b37c45000564bb78c9def03ff36ecdac909c0667492d83fc7
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ A RubyGem for integrating [Payload](https://payload.co).
|
|
7
7
|
To install using [Bundler](https://bundler.io):
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'payload-api', '~> 0.2.
|
10
|
+
gem 'payload-api', '~> 0.2.4'
|
11
11
|
```
|
12
12
|
|
13
13
|
To install using gem:
|
@@ -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
@@ -10,6 +10,7 @@ module Payload
|
|
10
10
|
|
11
11
|
def initialize(cls=nil)
|
12
12
|
@cls = cls
|
13
|
+
@selected_fields = ''
|
13
14
|
@filters = {}
|
14
15
|
end
|
15
16
|
|
@@ -17,7 +18,9 @@ module Payload
|
|
17
18
|
if @cls.poly
|
18
19
|
data = data.merge(@cls.poly)
|
19
20
|
end
|
20
|
-
|
21
|
+
|
22
|
+
@selected_fields = args.join(',')
|
23
|
+
|
21
24
|
return self
|
22
25
|
end
|
23
26
|
|
@@ -84,6 +87,14 @@ module Payload
|
|
84
87
|
end
|
85
88
|
|
86
89
|
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
|
+
|
87
98
|
if @cls.spec.key?("endpoint")
|
88
99
|
endpoint = @cls.spec["endpoint"]
|
89
100
|
else
|
@@ -125,7 +136,14 @@ module Payload
|
|
125
136
|
|
126
137
|
if response.code == '200'
|
127
138
|
if data['object'] == 'list'
|
128
|
-
return data['values'].map
|
139
|
+
return data['values'].map do |obj|
|
140
|
+
cls = Payload::get_cls(obj)
|
141
|
+
if cls.nil?
|
142
|
+
obj
|
143
|
+
else
|
144
|
+
cls.new(obj)
|
145
|
+
end
|
146
|
+
end
|
129
147
|
else
|
130
148
|
return Payload::get_cls(data).new(data)
|
131
149
|
end
|
data/lib/payload/version.rb
CHANGED
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.5
|
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-04-13 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.
|