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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7622a6cdd2bb9272244defec0d7270ac8ea332ac300c7b897797ec9b9311e4f6
4
- data.tar.gz: 2e640cddf0eb931313b4f4cdaa080a2a8e24471cc7330ed8ef6cc44f1c465f55
3
+ metadata.gz: 5783328f0a31aea836478841802815c16aaef86b22ff101c698b61603f1437cd
4
+ data.tar.gz: 4e606c81caaec76f7410e7e29c55c77261ae28b2c5b69c9191b62eb297a82d3f
5
5
  SHA512:
6
- metadata.gz: c77e7856968f9efa3cadd8c6625b401a2266f9725407c91a04fbc4b477a768a13d7a6e967c1175d53b627481ff47f2fb24a517d8d23e4276928b23e9259a9fde
7
- data.tar.gz: e4502563befa374e315924adc109c7e72bfdd8a29ce9d84c82c2ead3b55d619c9c89df54317644760d78a5b1bd68d1b6142b9faf27ffd9bf2e013e29f6e79841
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.3'
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 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
@@ -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 {|obj| Payload::get_cls(obj).new(obj) }
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
@@ -1,3 +1,3 @@
1
1
  module Payload
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.5'
3
3
  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.3
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-02-20 00:00:00.000000000 Z
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.