pingram 0.1.0 → 0.1.2
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/README.md +17 -5
- data/lib/pingram/api/templates_api.rb +82 -15
- data/lib/pingram/api_client.rb +1 -1
- data/lib/pingram/models/get_templates_list_response_inner.rb +108 -0
- data/lib/pingram/models/get_templates_list_response_inner_any_of.rb +449 -0
- data/lib/pingram/models/get_templates_list_response_inner_any_of1.rb +431 -0
- data/lib/pingram/models/get_templates_list_response_inner_any_of1_instant.rb +216 -0
- data/lib/pingram/models/get_templates_list_response_inner_any_of2.rb +327 -0
- data/lib/pingram/models/get_templates_list_response_inner_any_of3.rb +353 -0
- data/lib/pingram/models/get_templates_list_response_inner_any_of4.rb +371 -0
- data/lib/pingram/models/get_templates_list_response_inner_any_of5.rb +440 -0
- data/lib/pingram/models/{sender_post_body_slack_metadata.rb → get_templates_list_response_inner_any_of5_metadata.rb} +4 -4
- data/lib/pingram/models/{sender_post_body_slack_metadata_entities_inner.rb → get_templates_list_response_inner_any_of5_metadata_entities_inner.rb} +4 -4
- data/lib/pingram/models/{sender_post_body_slack_metadata_entities_inner_external_ref.rb → get_templates_list_response_inner_any_of5_metadata_entities_inner_external_ref.rb} +3 -3
- data/lib/pingram/models/get_templates_response.rb +3 -2
- data/lib/pingram/models/sender_post_body_slack.rb +1 -1
- data/lib/pingram/version.rb +1 -1
- data/lib/pingram.rb +11 -3
- data/pingram.gemspec +5 -5
- metadata +18 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 42272e0e1ca8a80a084cc5f4f089689bb2444fa67cd0bf99fa1c9abc6d7548ee
|
|
4
|
+
data.tar.gz: 3b0e60679b46b106fa7f06492cc39aa46408923e31112180fdec4b4cb3fd178e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: adb92ebea1d3ba20b16bf5e0f8bbac8aeacc0918564f7b87010afb5d02338e5079fae712a360c29deb8a7be88501f12ed34a27be9e66266457d6c7b2327b5041
|
|
7
|
+
data.tar.gz: '082590c797d513da21b88d422f5c7f165f12a9ab8c9814222c3f4bfa16e0bcaf81952b127160bc08b531df296b9fae807624409a2821ea77ae65f620b09aef6a'
|
data/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Pingram Ruby SDK
|
|
2
2
|
|
|
3
3
|
Official Ruby SDK for Pingram. Send notifications via Email, SMS, Push, In-App, and more from your server-side Ruby code.
|
|
4
4
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
7
7
|
- Ruby 2.4+
|
|
8
|
-
- Dependencies: see
|
|
8
|
+
- Dependencies: `faraday` (or configured HTTP library); see generated gem for details.
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -37,7 +37,7 @@ body = Pingram::SenderPostBody.new(
|
|
|
37
37
|
)
|
|
38
38
|
response = client.send(body)
|
|
39
39
|
|
|
40
|
-
# Or use namespaced APIs: client.default_api, client.
|
|
40
|
+
# Or use namespaced APIs: client.default_api, client.sender_api, client.account_api, ...
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
You can override the base URL: `Pingram::Client.new(api_key: '...', base_url: 'https://api.example.com')`.
|
|
@@ -45,9 +45,21 @@ You can override the base URL: `Pingram::Client.new(api_key: '...', base_url: 'h
|
|
|
45
45
|
## What can I call?
|
|
46
46
|
|
|
47
47
|
- **`client.send(body)`** – send a notification (high-level).
|
|
48
|
-
- **`client.domains`**, **`client.account`**, **`client.sender`**, etc. – low-level API objects
|
|
48
|
+
- **`client.domains`**, **`client.account`**, **`client.sender`**, etc. – low-level API objects. Each has methods like `domains_list_domains`, `account_get_account_details`, `sender_test_email`, and so on.
|
|
49
49
|
|
|
50
|
-
For the full list of methods, see **API_REFERENCE.md** in the
|
|
50
|
+
For the full list of methods on each API, see **[API_REFERENCE.md](API_REFERENCE.md)** (in this directory). It is generated from the OpenAPI spec when you run codegen.
|
|
51
|
+
|
|
52
|
+
## Generating the SDK
|
|
53
|
+
|
|
54
|
+
From the `serverless/` directory (or repo root with correct paths):
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm run codegen:sdk
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This generates the OpenAPI spec and all SDKs, including Ruby, into `sdks/ruby/generated/`.
|
|
61
|
+
|
|
62
|
+
**Adding new endpoints:** You do **not** need to change the Ruby wrapper or generator. Update the OpenAPI spec (new paths and tags), then run `npm run codegen:sdk`. The wrapper and `API_REFERENCE.md` are derived from the spec (tags) and generated API files, so new APIs and methods appear automatically.
|
|
51
63
|
|
|
52
64
|
## Links
|
|
53
65
|
|
|
@@ -168,6 +168,79 @@ module Pingram
|
|
|
168
168
|
return data, status_code, headers
|
|
169
169
|
end
|
|
170
170
|
|
|
171
|
+
# Get a single template by ID
|
|
172
|
+
# @param notification_id [String] Notification ID
|
|
173
|
+
# @param channel [String] Channel type
|
|
174
|
+
# @param template_id [String] Template ID
|
|
175
|
+
# @param [Hash] opts the optional parameters
|
|
176
|
+
# @return [GetTemplatesResponse]
|
|
177
|
+
def templates_get_template(notification_id, channel, template_id, opts = {})
|
|
178
|
+
data, _status_code, _headers = templates_get_template_with_http_info(notification_id, channel, template_id, opts)
|
|
179
|
+
data
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# Get a single template by ID
|
|
183
|
+
# @param notification_id [String] Notification ID
|
|
184
|
+
# @param channel [String] Channel type
|
|
185
|
+
# @param template_id [String] Template ID
|
|
186
|
+
# @param [Hash] opts the optional parameters
|
|
187
|
+
# @return [Array<(GetTemplatesResponse, Integer, Hash)>] GetTemplatesResponse data, response status code and response headers
|
|
188
|
+
def templates_get_template_with_http_info(notification_id, channel, template_id, opts = {})
|
|
189
|
+
if @api_client.config.debugging
|
|
190
|
+
@api_client.config.logger.debug 'Calling API: TemplatesApi.templates_get_template ...'
|
|
191
|
+
end
|
|
192
|
+
# verify the required parameter 'notification_id' is set
|
|
193
|
+
if @api_client.config.client_side_validation && notification_id.nil?
|
|
194
|
+
fail ArgumentError, "Missing the required parameter 'notification_id' when calling TemplatesApi.templates_get_template"
|
|
195
|
+
end
|
|
196
|
+
# verify the required parameter 'channel' is set
|
|
197
|
+
if @api_client.config.client_side_validation && channel.nil?
|
|
198
|
+
fail ArgumentError, "Missing the required parameter 'channel' when calling TemplatesApi.templates_get_template"
|
|
199
|
+
end
|
|
200
|
+
# verify the required parameter 'template_id' is set
|
|
201
|
+
if @api_client.config.client_side_validation && template_id.nil?
|
|
202
|
+
fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.templates_get_template"
|
|
203
|
+
end
|
|
204
|
+
# resource path
|
|
205
|
+
local_var_path = '/notifications/{notificationId}/{channel}/templates/{templateId}'.sub('{' + 'notificationId' + '}', CGI.escape(notification_id.to_s)).sub('{' + 'channel' + '}', CGI.escape(channel.to_s)).sub('{' + 'templateId' + '}', CGI.escape(template_id.to_s))
|
|
206
|
+
|
|
207
|
+
# query parameters
|
|
208
|
+
query_params = opts[:query_params] || {}
|
|
209
|
+
|
|
210
|
+
# header parameters
|
|
211
|
+
header_params = opts[:header_params] || {}
|
|
212
|
+
# HTTP header 'Accept' (if needed)
|
|
213
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
214
|
+
|
|
215
|
+
# form parameters
|
|
216
|
+
form_params = opts[:form_params] || {}
|
|
217
|
+
|
|
218
|
+
# http body (model)
|
|
219
|
+
post_body = opts[:debug_body]
|
|
220
|
+
|
|
221
|
+
# return_type
|
|
222
|
+
return_type = opts[:debug_return_type] || 'GetTemplatesResponse'
|
|
223
|
+
|
|
224
|
+
# auth_names (apiKey last so Bearer wins when multiple schemes set Authorization)
|
|
225
|
+
auth_names = opts[:debug_auth_names] || ['endUserHashed', 'endUser', 'clientCredentials', 'apiKey']
|
|
226
|
+
|
|
227
|
+
new_options = opts.merge(
|
|
228
|
+
:operation => :"TemplatesApi.templates_get_template",
|
|
229
|
+
:header_params => header_params,
|
|
230
|
+
:query_params => query_params,
|
|
231
|
+
:form_params => form_params,
|
|
232
|
+
:body => post_body,
|
|
233
|
+
:auth_names => auth_names,
|
|
234
|
+
:return_type => return_type
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
238
|
+
if @api_client.config.debugging
|
|
239
|
+
@api_client.config.logger.debug "API called: TemplatesApi#templates_get_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
240
|
+
end
|
|
241
|
+
return data, status_code, headers
|
|
242
|
+
end
|
|
243
|
+
|
|
171
244
|
# Initiate AI-powered template migration from complex to simple HTML
|
|
172
245
|
# @param notification_id [String] Notification ID
|
|
173
246
|
# @param channel [String] Channel type
|
|
@@ -241,24 +314,22 @@ module Pingram
|
|
|
241
314
|
return data, status_code, headers
|
|
242
315
|
end
|
|
243
316
|
|
|
244
|
-
#
|
|
317
|
+
# List all templates for a notification and channel
|
|
245
318
|
# @param notification_id [String] Notification ID
|
|
246
319
|
# @param channel [String] Channel type
|
|
247
|
-
# @param template_id [String] Template ID (optional for listing all)
|
|
248
320
|
# @param [Hash] opts the optional parameters
|
|
249
|
-
# @return [
|
|
250
|
-
def templates_list_templates(notification_id, channel,
|
|
251
|
-
data, _status_code, _headers = templates_list_templates_with_http_info(notification_id, channel,
|
|
321
|
+
# @return [Array<GetTemplatesListResponseInner>]
|
|
322
|
+
def templates_list_templates(notification_id, channel, opts = {})
|
|
323
|
+
data, _status_code, _headers = templates_list_templates_with_http_info(notification_id, channel, opts)
|
|
252
324
|
data
|
|
253
325
|
end
|
|
254
326
|
|
|
255
|
-
#
|
|
327
|
+
# List all templates for a notification and channel
|
|
256
328
|
# @param notification_id [String] Notification ID
|
|
257
329
|
# @param channel [String] Channel type
|
|
258
|
-
# @param template_id [String] Template ID (optional for listing all)
|
|
259
330
|
# @param [Hash] opts the optional parameters
|
|
260
|
-
# @return [Array<(
|
|
261
|
-
def templates_list_templates_with_http_info(notification_id, channel,
|
|
331
|
+
# @return [Array<(Array<GetTemplatesListResponseInner>, Integer, Hash)>] Array<GetTemplatesListResponseInner> data, response status code and response headers
|
|
332
|
+
def templates_list_templates_with_http_info(notification_id, channel, opts = {})
|
|
262
333
|
if @api_client.config.debugging
|
|
263
334
|
@api_client.config.logger.debug 'Calling API: TemplatesApi.templates_list_templates ...'
|
|
264
335
|
end
|
|
@@ -270,12 +341,8 @@ module Pingram
|
|
|
270
341
|
if @api_client.config.client_side_validation && channel.nil?
|
|
271
342
|
fail ArgumentError, "Missing the required parameter 'channel' when calling TemplatesApi.templates_list_templates"
|
|
272
343
|
end
|
|
273
|
-
# verify the required parameter 'template_id' is set
|
|
274
|
-
if @api_client.config.client_side_validation && template_id.nil?
|
|
275
|
-
fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.templates_list_templates"
|
|
276
|
-
end
|
|
277
344
|
# resource path
|
|
278
|
-
local_var_path = '/notifications/{notificationId}/{channel}/templates
|
|
345
|
+
local_var_path = '/notifications/{notificationId}/{channel}/templates'.sub('{' + 'notificationId' + '}', CGI.escape(notification_id.to_s)).sub('{' + 'channel' + '}', CGI.escape(channel.to_s))
|
|
279
346
|
|
|
280
347
|
# query parameters
|
|
281
348
|
query_params = opts[:query_params] || {}
|
|
@@ -292,7 +359,7 @@ module Pingram
|
|
|
292
359
|
post_body = opts[:debug_body]
|
|
293
360
|
|
|
294
361
|
# return_type
|
|
295
|
-
return_type = opts[:debug_return_type] || '
|
|
362
|
+
return_type = opts[:debug_return_type] || 'Array<GetTemplatesListResponseInner>'
|
|
296
363
|
|
|
297
364
|
# auth_names (apiKey last so Bearer wins when multiple schemes set Authorization)
|
|
298
365
|
auth_names = opts[:debug_auth_names] || ['endUserHashed', 'endUser', 'clientCredentials', 'apiKey']
|
data/lib/pingram/api_client.rb
CHANGED
|
@@ -32,7 +32,7 @@ module Pingram
|
|
|
32
32
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
|
33
33
|
def initialize(config = Configuration.default)
|
|
34
34
|
@config = config
|
|
35
|
-
@user_agent = "pingram-ruby/0.1.
|
|
35
|
+
@user_agent = "pingram-ruby/0.1.2"
|
|
36
36
|
@default_headers = {
|
|
37
37
|
'Content-Type' => 'application/json',
|
|
38
38
|
'User-Agent' => @user_agent
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#NotificationAPI
|
|
3
|
+
|
|
4
|
+
#Internal API for notification delivery and management
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.19.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module Pingram
|
|
17
|
+
# Union of all channel-specific template types. Used for API responses that can return any template type.
|
|
18
|
+
module GetTemplatesListResponseInner
|
|
19
|
+
class << self
|
|
20
|
+
# List of class defined in anyOf (OpenAPI v3)
|
|
21
|
+
def openapi_any_of
|
|
22
|
+
[
|
|
23
|
+
:'GetTemplatesListResponseInnerAnyOf',
|
|
24
|
+
:'GetTemplatesListResponseInnerAnyOf1',
|
|
25
|
+
:'GetTemplatesListResponseInnerAnyOf2',
|
|
26
|
+
:'GetTemplatesListResponseInnerAnyOf3',
|
|
27
|
+
:'GetTemplatesListResponseInnerAnyOf4',
|
|
28
|
+
:'GetTemplatesListResponseInnerAnyOf5'
|
|
29
|
+
]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Builds the object
|
|
33
|
+
# @param [Mixed] Data to be matched against the list of anyOf items
|
|
34
|
+
# @return [Object] Returns the model or the data itself
|
|
35
|
+
def build(data)
|
|
36
|
+
# Go through the list of anyOf items and attempt to identify the appropriate one.
|
|
37
|
+
# Note:
|
|
38
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
39
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
40
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
41
|
+
# - TODO: logging when debugging is set.
|
|
42
|
+
openapi_any_of.each do |klass|
|
|
43
|
+
begin
|
|
44
|
+
next if klass == :AnyType # "nullable: true"
|
|
45
|
+
return find_and_cast_into_type(klass, data)
|
|
46
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
openapi_any_of.include?(:AnyType) ? data : nil
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
SchemaMismatchError = Class.new(StandardError)
|
|
56
|
+
|
|
57
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
|
58
|
+
def find_and_cast_into_type(klass, data)
|
|
59
|
+
return if data.nil?
|
|
60
|
+
|
|
61
|
+
case klass.to_s
|
|
62
|
+
when 'Boolean'
|
|
63
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
64
|
+
when 'Float'
|
|
65
|
+
return data if data.instance_of?(Float)
|
|
66
|
+
when 'Integer'
|
|
67
|
+
return data if data.instance_of?(Integer)
|
|
68
|
+
when 'Time'
|
|
69
|
+
return Time.parse(data)
|
|
70
|
+
when 'Date'
|
|
71
|
+
return Date.iso8601(data)
|
|
72
|
+
when 'String'
|
|
73
|
+
return data if data.instance_of?(String)
|
|
74
|
+
when 'Object' # "type: object"
|
|
75
|
+
return data if data.instance_of?(Hash)
|
|
76
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
77
|
+
if data.instance_of?(Array)
|
|
78
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
79
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
80
|
+
end
|
|
81
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
82
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
83
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
84
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
85
|
+
end
|
|
86
|
+
else # model
|
|
87
|
+
const = Pingram.const_get(klass)
|
|
88
|
+
if const
|
|
89
|
+
if const.respond_to?(:openapi_any_of) # nested anyOf model
|
|
90
|
+
model = const.build(data)
|
|
91
|
+
return model if model
|
|
92
|
+
else
|
|
93
|
+
# raise if data contains keys that are not known to the model
|
|
94
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
95
|
+
model = const.build_from_hash(data)
|
|
96
|
+
return model if model
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
raise # if no match by now, raise
|
|
102
|
+
rescue
|
|
103
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
end
|