rcs 1.0.15 → 1.0.16

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: cd6b24540486cc673f369e84cd9c3a56d58837b4143a11f79b0b8ad8d7056ee4
4
- data.tar.gz: 708a541bf38d32fde5b6ef6d6338d9e3494f681f60d5811dbbc384e0bb58cf02
3
+ metadata.gz: 0cc0ed650419f2955313e2c91055c00a20c376af7b19fca0a067c575e39cb441
4
+ data.tar.gz: 0114e52c609971adb0f70222a9eda7be72ed2c21cbaab3edf6412a3586419c4d
5
5
  SHA512:
6
- metadata.gz: b4fc78e103e1274d2ceac57826ce3bd7772901e5222fe486d2e133e3b2bd3570e26506db5438e699986b0a1bbdd9c0ae843e1e5fb8eef5f997e8df22886a2b8f
7
- data.tar.gz: cf3dfa9bc7e5ad188baefef9983d6f1ac5230eafa3d08c9a9006581feb5f774bfd6213acdf0191f80f7985385fab06e2dccd6f8b00c684f637079052d2bd57c1
6
+ metadata.gz: f814ccaa8ebb9566fd17e1f5d067605f60ef77e5becb1e66c336eb6feda96aa42b384d3d04dcfb6ec89ae0e2d4e48d0516750b7c0c35fafc52cbb2faf139cb53
7
+ data.tar.gz: 1c5530bf2ad1d6589b6e445929ca77aa7dd0e80c726faa93cda11e4e335fb0002aa8bad60f9f2de9ca4d60f34b18a8a9118c3bf416b6d292412d5639654ab274
@@ -0,0 +1,207 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../requests"
4
+ require "date"
5
+ require_relative "types/tools_shorten_url_response"
6
+ require_relative "types/tools_upload_url_response"
7
+ require "async"
8
+
9
+ module Pinnacle
10
+ class ToolsClient
11
+ # @return [Pinnacle::RequestClient]
12
+ attr_reader :request_client
13
+
14
+ # @param request_client [Pinnacle::RequestClient]
15
+ # @return [Pinnacle::ToolsClient]
16
+ def initialize(request_client:)
17
+ @request_client = request_client
18
+ end
19
+
20
+ # Create a shortened URL with an optional expiration date (default and max
21
+ # expiration is 90 days). The shortened URL will redirect to the original URL and
22
+ # will have the following format https://urls.p1n.io/ABCD5678.
23
+ #
24
+ # @param url [String] The URL to be shortened. Must be a valid URL with either http or https protocol.
25
+ # @param expires_at [DateTime] Optional expiration date for the shortened URL in ISO 8601 format. Default and
26
+ # max expiration is 90 days.
27
+ # @param request_options [Pinnacle::RequestOptions]
28
+ # @return [Pinnacle::Tools::ToolsShortenUrlResponse]
29
+ # @example
30
+ # api = Pinnacle::Client.new(
31
+ # base_url: "https://api.example.com",
32
+ # environment: Pinnacle::Environment::DEFAULT,
33
+ # api_key: "YOUR_API_KEY"
34
+ # )
35
+ # api.tools.shorten_url(url: "https://example.com")
36
+ def shorten_url(url:, expires_at: nil, request_options: nil)
37
+ response = @request_client.conn.post do |req|
38
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
39
+ req.headers["PINNACLE-API-Key"] = request_options.api_key unless request_options&.api_key.nil?
40
+ req.headers = {
41
+ **(req.headers || {}),
42
+ **@request_client.get_headers,
43
+ **(request_options&.additional_headers || {})
44
+ }.compact
45
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
46
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
47
+ end
48
+ req.body = { **(request_options&.additional_body_parameters || {}), url: url, expiresAt: expires_at }.compact
49
+ req.url "#{@request_client.get_url(request_options: request_options)}/tools/urls/shorten"
50
+ end
51
+ Pinnacle::Tools::ToolsShortenUrlResponse.from_json(json_object: response.body)
52
+ end
53
+
54
+ # Generate signed upload (expires in 2 hours) and download URLs for a file
55
+ # (expires in 1 hour).
56
+ #
57
+ # @param content_type [String] The MIME type of the file.
58
+ # Supported types are audio/basic, audio/L24, audio/mp4, audio/mpeg, audio/mpg,
59
+ # audio/mp3, audio/ogg, audio/aac, audio/vndrn-realaudio, audio/vndwave,
60
+ # audio/3gpp, audio/3gpp2, audio/ac3, audio/webm, audio/amrnb, audio/amr,
61
+ # video/mpeg, video/mp4, video/quicktime, video/webm, video/3gpp, video/3gpp2,
62
+ # video/3gpptt, video/H261, video/H263, video/H2631998, video/H2632000,
63
+ # video/H264, video/m4v, video/mpeg4, video/webm, image/jpeg, image/gif,
64
+ # image/png, image/gif, image/bmp, image/tiff, image/webp, text/vcard,
65
+ # text/xvcard, text/csv, text/rtf, text/richtext, text/calendar, text/directory,
66
+ # application/ogg, application/pdf, application/vcard,
67
+ # application/vndapple.pkpass.
68
+ # @param size [Integer] The size of the file in bytes. Should be less than 100 MB.
69
+ # @param name [String] The name of the file.
70
+ # @param request_options [Pinnacle::RequestOptions]
71
+ # @return [Pinnacle::Tools::ToolsUploadUrlResponse]
72
+ # @example
73
+ # api = Pinnacle::Client.new(
74
+ # base_url: "https://api.example.com",
75
+ # environment: Pinnacle::Environment::DEFAULT,
76
+ # api_key: "YOUR_API_KEY"
77
+ # )
78
+ # api.tools.upload_url(
79
+ # content_type: "image/png",
80
+ # size: 1024,
81
+ # name: "example.png"
82
+ # )
83
+ def upload_url(content_type:, size:, name:, request_options: nil)
84
+ response = @request_client.conn.post do |req|
85
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
86
+ req.headers["PINNACLE-API-Key"] = request_options.api_key unless request_options&.api_key.nil?
87
+ req.headers = {
88
+ **(req.headers || {}),
89
+ **@request_client.get_headers,
90
+ **(request_options&.additional_headers || {})
91
+ }.compact
92
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
93
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
94
+ end
95
+ req.body = {
96
+ **(request_options&.additional_body_parameters || {}),
97
+ contentType: content_type,
98
+ size: size,
99
+ name: name
100
+ }.compact
101
+ req.url "#{@request_client.get_url(request_options: request_options)}/tools/uploadUrl"
102
+ end
103
+ Pinnacle::Tools::ToolsUploadUrlResponse.from_json(json_object: response.body)
104
+ end
105
+ end
106
+
107
+ class AsyncToolsClient
108
+ # @return [Pinnacle::AsyncRequestClient]
109
+ attr_reader :request_client
110
+
111
+ # @param request_client [Pinnacle::AsyncRequestClient]
112
+ # @return [Pinnacle::AsyncToolsClient]
113
+ def initialize(request_client:)
114
+ @request_client = request_client
115
+ end
116
+
117
+ # Create a shortened URL with an optional expiration date (default and max
118
+ # expiration is 90 days). The shortened URL will redirect to the original URL and
119
+ # will have the following format https://urls.p1n.io/ABCD5678.
120
+ #
121
+ # @param url [String] The URL to be shortened. Must be a valid URL with either http or https protocol.
122
+ # @param expires_at [DateTime] Optional expiration date for the shortened URL in ISO 8601 format. Default and
123
+ # max expiration is 90 days.
124
+ # @param request_options [Pinnacle::RequestOptions]
125
+ # @return [Pinnacle::Tools::ToolsShortenUrlResponse]
126
+ # @example
127
+ # api = Pinnacle::Client.new(
128
+ # base_url: "https://api.example.com",
129
+ # environment: Pinnacle::Environment::DEFAULT,
130
+ # api_key: "YOUR_API_KEY"
131
+ # )
132
+ # api.tools.shorten_url(url: "https://example.com")
133
+ def shorten_url(url:, expires_at: nil, request_options: nil)
134
+ Async do
135
+ response = @request_client.conn.post do |req|
136
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
137
+ req.headers["PINNACLE-API-Key"] = request_options.api_key unless request_options&.api_key.nil?
138
+ req.headers = {
139
+ **(req.headers || {}),
140
+ **@request_client.get_headers,
141
+ **(request_options&.additional_headers || {})
142
+ }.compact
143
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
144
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
145
+ end
146
+ req.body = { **(request_options&.additional_body_parameters || {}), url: url, expiresAt: expires_at }.compact
147
+ req.url "#{@request_client.get_url(request_options: request_options)}/tools/urls/shorten"
148
+ end
149
+ Pinnacle::Tools::ToolsShortenUrlResponse.from_json(json_object: response.body)
150
+ end
151
+ end
152
+
153
+ # Generate signed upload (expires in 2 hours) and download URLs for a file
154
+ # (expires in 1 hour).
155
+ #
156
+ # @param content_type [String] The MIME type of the file.
157
+ # Supported types are audio/basic, audio/L24, audio/mp4, audio/mpeg, audio/mpg,
158
+ # audio/mp3, audio/ogg, audio/aac, audio/vndrn-realaudio, audio/vndwave,
159
+ # audio/3gpp, audio/3gpp2, audio/ac3, audio/webm, audio/amrnb, audio/amr,
160
+ # video/mpeg, video/mp4, video/quicktime, video/webm, video/3gpp, video/3gpp2,
161
+ # video/3gpptt, video/H261, video/H263, video/H2631998, video/H2632000,
162
+ # video/H264, video/m4v, video/mpeg4, video/webm, image/jpeg, image/gif,
163
+ # image/png, image/gif, image/bmp, image/tiff, image/webp, text/vcard,
164
+ # text/xvcard, text/csv, text/rtf, text/richtext, text/calendar, text/directory,
165
+ # application/ogg, application/pdf, application/vcard,
166
+ # application/vndapple.pkpass.
167
+ # @param size [Integer] The size of the file in bytes. Should be less than 100 MB.
168
+ # @param name [String] The name of the file.
169
+ # @param request_options [Pinnacle::RequestOptions]
170
+ # @return [Pinnacle::Tools::ToolsUploadUrlResponse]
171
+ # @example
172
+ # api = Pinnacle::Client.new(
173
+ # base_url: "https://api.example.com",
174
+ # environment: Pinnacle::Environment::DEFAULT,
175
+ # api_key: "YOUR_API_KEY"
176
+ # )
177
+ # api.tools.upload_url(
178
+ # content_type: "image/png",
179
+ # size: 1024,
180
+ # name: "example.png"
181
+ # )
182
+ def upload_url(content_type:, size:, name:, request_options: nil)
183
+ Async do
184
+ response = @request_client.conn.post do |req|
185
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
186
+ req.headers["PINNACLE-API-Key"] = request_options.api_key unless request_options&.api_key.nil?
187
+ req.headers = {
188
+ **(req.headers || {}),
189
+ **@request_client.get_headers,
190
+ **(request_options&.additional_headers || {})
191
+ }.compact
192
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
193
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
194
+ end
195
+ req.body = {
196
+ **(request_options&.additional_body_parameters || {}),
197
+ contentType: content_type,
198
+ size: size,
199
+ name: name
200
+ }.compact
201
+ req.url "#{@request_client.get_url(request_options: request_options)}/tools/uploadUrl"
202
+ end
203
+ Pinnacle::Tools::ToolsUploadUrlResponse.from_json(json_object: response.body)
204
+ end
205
+ end
206
+ end
207
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module Pinnacle
8
+ class Tools
9
+ class ToolsShortenUrlResponse
10
+ # @return [String] The shortened URL.
11
+ attr_reader :shortened_url
12
+ # @return [DateTime] The expiration date of the shortened URL, if provided.
13
+ attr_reader :expires_at
14
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
15
+ attr_reader :additional_properties
16
+ # @return [Object]
17
+ attr_reader :_field_set
18
+ protected :_field_set
19
+
20
+ OMIT = Object.new
21
+
22
+ # @param shortened_url [String] The shortened URL.
23
+ # @param expires_at [DateTime] The expiration date of the shortened URL, if provided.
24
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
25
+ # @return [Pinnacle::Tools::ToolsShortenUrlResponse]
26
+ def initialize(shortened_url: OMIT, expires_at: OMIT, additional_properties: nil)
27
+ @shortened_url = shortened_url if shortened_url != OMIT
28
+ @expires_at = expires_at if expires_at != OMIT
29
+ @additional_properties = additional_properties
30
+ @_field_set = { "shortenedUrl": shortened_url, "expiresAt": expires_at }.reject do |_k, v|
31
+ v == OMIT
32
+ end
33
+ end
34
+
35
+ # Deserialize a JSON object to an instance of ToolsShortenUrlResponse
36
+ #
37
+ # @param json_object [String]
38
+ # @return [Pinnacle::Tools::ToolsShortenUrlResponse]
39
+ def self.from_json(json_object:)
40
+ struct = JSON.parse(json_object, object_class: OpenStruct)
41
+ parsed_json = JSON.parse(json_object)
42
+ shortened_url = parsed_json["shortenedUrl"]
43
+ expires_at = (DateTime.parse(parsed_json["expiresAt"]) unless parsed_json["expiresAt"].nil?)
44
+ new(
45
+ shortened_url: shortened_url,
46
+ expires_at: expires_at,
47
+ additional_properties: struct
48
+ )
49
+ end
50
+
51
+ # Serialize an instance of ToolsShortenUrlResponse to a JSON object
52
+ #
53
+ # @return [String]
54
+ def to_json(*_args)
55
+ @_field_set&.to_json
56
+ end
57
+
58
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
59
+ # hash and check each fields type against the current object's property
60
+ # definitions.
61
+ #
62
+ # @param obj [Object]
63
+ # @return [Void]
64
+ def self.validate_raw(obj:)
65
+ obj.shortened_url&.is_a?(String) != false || raise("Passed value for field obj.shortened_url is not the expected type, validation failed.")
66
+ obj.expires_at&.is_a?(DateTime) != false || raise("Passed value for field obj.expires_at is not the expected type, validation failed.")
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Pinnacle
7
+ class Tools
8
+ class ToolsUploadUrlResponse
9
+ # @return [String] The URL to upload the file.
10
+ attr_reader :upload
11
+ # @return [String] The URL to download the file.
12
+ attr_reader :download
13
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
14
+ attr_reader :additional_properties
15
+ # @return [Object]
16
+ attr_reader :_field_set
17
+ protected :_field_set
18
+
19
+ OMIT = Object.new
20
+
21
+ # @param upload [String] The URL to upload the file.
22
+ # @param download [String] The URL to download the file.
23
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
+ # @return [Pinnacle::Tools::ToolsUploadUrlResponse]
25
+ def initialize(upload: OMIT, download: OMIT, additional_properties: nil)
26
+ @upload = upload if upload != OMIT
27
+ @download = download if download != OMIT
28
+ @additional_properties = additional_properties
29
+ @_field_set = { "upload": upload, "download": download }.reject do |_k, v|
30
+ v == OMIT
31
+ end
32
+ end
33
+
34
+ # Deserialize a JSON object to an instance of ToolsUploadUrlResponse
35
+ #
36
+ # @param json_object [String]
37
+ # @return [Pinnacle::Tools::ToolsUploadUrlResponse]
38
+ def self.from_json(json_object:)
39
+ struct = JSON.parse(json_object, object_class: OpenStruct)
40
+ parsed_json = JSON.parse(json_object)
41
+ upload = parsed_json["upload"]
42
+ download = parsed_json["download"]
43
+ new(
44
+ upload: upload,
45
+ download: download,
46
+ additional_properties: struct
47
+ )
48
+ end
49
+
50
+ # Serialize an instance of ToolsUploadUrlResponse to a JSON object
51
+ #
52
+ # @return [String]
53
+ def to_json(*_args)
54
+ @_field_set&.to_json
55
+ end
56
+
57
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
58
+ # hash and check each fields type against the current object's property
59
+ # definitions.
60
+ #
61
+ # @param obj [Object]
62
+ # @return [Void]
63
+ def self.validate_raw(obj:)
64
+ obj.upload&.is_a?(String) != false || raise("Passed value for field obj.upload is not the expected type, validation failed.")
65
+ obj.download&.is_a?(String) != false || raise("Passed value for field obj.download is not the expected type, validation failed.")
66
+ end
67
+ end
68
+ end
69
+ end
data/lib/rcs.rb CHANGED
@@ -5,6 +5,7 @@ require_relative "types_export"
5
5
  require_relative "requests"
6
6
  require_relative "rcs/company/client"
7
7
  require_relative "rcs/send/client"
8
+ require_relative "rcs/tools/client"
8
9
  require_relative "rcs/types/rcs_functionalities"
9
10
 
10
11
  module Pinnacle
@@ -13,6 +14,8 @@ module Pinnacle
13
14
  attr_reader :company
14
15
  # @return [Pinnacle::SendClient]
15
16
  attr_reader :send
17
+ # @return [Pinnacle::ToolsClient]
18
+ attr_reader :tools
16
19
 
17
20
  # @param base_url [String]
18
21
  # @param environment [Pinnacle::Environment]
@@ -31,6 +34,7 @@ module Pinnacle
31
34
  )
32
35
  @company = Pinnacle::CompanyClient.new(request_client: @request_client)
33
36
  @send = Pinnacle::SendClient.new(request_client: @request_client)
37
+ @tools = Pinnacle::ToolsClient.new(request_client: @request_client)
34
38
  end
35
39
 
36
40
  # Retrieve the RCS functionality of a phone number. For example checks if a phone
@@ -71,6 +75,8 @@ module Pinnacle
71
75
  attr_reader :company
72
76
  # @return [Pinnacle::AsyncSendClient]
73
77
  attr_reader :send
78
+ # @return [Pinnacle::AsyncToolsClient]
79
+ attr_reader :tools
74
80
 
75
81
  # @param base_url [String]
76
82
  # @param environment [Pinnacle::Environment]
@@ -89,6 +95,7 @@ module Pinnacle
89
95
  )
90
96
  @company = Pinnacle::AsyncCompanyClient.new(request_client: @async_request_client)
91
97
  @send = Pinnacle::AsyncSendClient.new(request_client: @async_request_client)
98
+ @tools = Pinnacle::AsyncToolsClient.new(request_client: @async_request_client)
92
99
  end
93
100
 
94
101
  # Retrieve the RCS functionality of a phone number. For example checks if a phone
data/lib/requests.rb CHANGED
@@ -43,7 +43,7 @@ module Pinnacle
43
43
 
44
44
  # @return [Hash{String => String}]
45
45
  def get_headers
46
- headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "rcs", "X-Fern-SDK-Version": "1.0.15" }
46
+ headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "rcs", "X-Fern-SDK-Version": "1.0.16" }
47
47
  headers["PINNACLE-API-Key"] = ((@api_key.is_a? Method) ? @api_key.call : @api_key) unless @api_key.nil?
48
48
  headers
49
49
  end
@@ -87,7 +87,7 @@ module Pinnacle
87
87
 
88
88
  # @return [Hash{String => String}]
89
89
  def get_headers
90
- headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "rcs", "X-Fern-SDK-Version": "1.0.15" }
90
+ headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "rcs", "X-Fern-SDK-Version": "1.0.16" }
91
91
  headers["PINNACLE-API-Key"] = ((@api_key.is_a? Method) ? @api_key.call : @api_key) unless @api_key.nil?
92
92
  headers
93
93
  end
data/lib/types_export.rb CHANGED
@@ -8,6 +8,8 @@ require_relative "rcs/send/types/rcs_fallback"
8
8
  require_relative "rcs/send/types/send_rcs_response"
9
9
  require_relative "rcs/send/types/send_sms_response"
10
10
  require_relative "rcs/send/types/send_mms_response"
11
+ require_relative "rcs/tools/types/tools_shorten_url_response"
12
+ require_relative "rcs/tools/types/tools_upload_url_response"
11
13
  require_relative "rcs/types/bad_request_error_body"
12
14
  require_relative "rcs/types/unauthorized_error_body"
13
15
  require_relative "rcs/types/internal_server_error_body"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.15
4
+ version: 1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-29 00:00:00.000000000 Z
11
+ date: 2024-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http-faraday
@@ -109,6 +109,9 @@ files:
109
109
  - lib/rcs/send/types/send_mms_response.rb
110
110
  - lib/rcs/send/types/send_rcs_response.rb
111
111
  - lib/rcs/send/types/send_sms_response.rb
112
+ - lib/rcs/tools/client.rb
113
+ - lib/rcs/tools/types/tools_shorten_url_response.rb
114
+ - lib/rcs/tools/types/tools_upload_url_response.rb
112
115
  - lib/rcs/types/action.rb
113
116
  - lib/rcs/types/action_lat_long.rb
114
117
  - lib/rcs/types/action_type.rb