rcs 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/lib/environment.rb +7 -0
  3. data/lib/gemconfig.rb +14 -0
  4. data/lib/rcs/company/client.rb +416 -0
  5. data/lib/rcs/company/types/company_register_response.rb +63 -0
  6. data/lib/rcs/company/types/company_register_response_brand.rb +67 -0
  7. data/lib/rcs/company/types/company_update_response.rb +63 -0
  8. data/lib/rcs/company/types/company_update_response_brand.rb +67 -0
  9. data/lib/rcs/send/client.rb +343 -0
  10. data/lib/rcs/send/types/send_mms_response.rb +67 -0
  11. data/lib/rcs/send/types/send_rcs_response.rb +67 -0
  12. data/lib/rcs/send/types/send_sms_response.rb +67 -0
  13. data/lib/rcs/types/action.rb +146 -0
  14. data/lib/rcs/types/action_lat_long.rb +68 -0
  15. data/lib/rcs/types/action_type.rb +16 -0
  16. data/lib/rcs/types/additional_email.rb +65 -0
  17. data/lib/rcs/types/additional_phone_number.rb +65 -0
  18. data/lib/rcs/types/additional_website.rb +65 -0
  19. data/lib/rcs/types/bad_request_error_body.rb +57 -0
  20. data/lib/rcs/types/card.rb +90 -0
  21. data/lib/rcs/types/company.rb +268 -0
  22. data/lib/rcs/types/company_additional_emails_item.rb +67 -0
  23. data/lib/rcs/types/company_additional_phone_numbers_item.rb +67 -0
  24. data/lib/rcs/types/company_additional_websites_item.rb +67 -0
  25. data/lib/rcs/types/company_contact.rb +117 -0
  26. data/lib/rcs/types/company_details.rb +110 -0
  27. data/lib/rcs/types/forbidden_error_body.rb +57 -0
  28. data/lib/rcs/types/internal_server_error_body.rb +57 -0
  29. data/lib/rcs/types/optionals.rb +99 -0
  30. data/lib/rcs/types/point_of_contact.rb +72 -0
  31. data/lib/rcs/types/rcs_functionalities.rb +117 -0
  32. data/lib/rcs/types/unauthorized_error_body.rb +57 -0
  33. data/lib/rcs.rb +126 -0
  34. data/lib/requests.rb +163 -0
  35. data/lib/types_export.rb +29 -0
  36. metadata +158 -0
data/lib/rcs.rb ADDED
@@ -0,0 +1,126 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "environment"
4
+ require_relative "types_export"
5
+ require_relative "requests"
6
+ require_relative "rcs/company/client"
7
+ require_relative "rcs/send/client"
8
+ require_relative "rcs/types/rcs_functionalities"
9
+
10
+ module Pinnacle
11
+ class Client
12
+ # @return [Pinnacle::CompanyClient]
13
+ attr_reader :company
14
+ # @return [Pinnacle::SendClient]
15
+ attr_reader :send
16
+
17
+ # @param base_url [String]
18
+ # @param environment [Pinnacle::Environment]
19
+ # @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
20
+ # @param timeout_in_seconds [Long]
21
+ # @param api_key [String]
22
+ # @return [Pinnacle::Client]
23
+ def initialize(api_key:, base_url: nil, environment: Pinnacle::Environment::DEFAULT, max_retries: nil,
24
+ timeout_in_seconds: nil)
25
+ @request_client = Pinnacle::RequestClient.new(
26
+ base_url: base_url,
27
+ environment: environment,
28
+ max_retries: max_retries,
29
+ timeout_in_seconds: timeout_in_seconds,
30
+ api_key: api_key
31
+ )
32
+ @company = Pinnacle::CompanyClient.new(request_client: @request_client)
33
+ @send = Pinnacle::SendClient.new(request_client: @request_client)
34
+ end
35
+
36
+ # Retrieve the RCS functionality of a phone number. For example checks if a phone
37
+ # number can receive RCS message and if it can receive RCS carousels.
38
+ #
39
+ # @param phone_number [String] The phone number to check for RCS functionality. Should be in E.164 format (i.e.
40
+ # +12345678901).
41
+ # @param request_options [Pinnacle::RequestOptions]
42
+ # @return [Pinnacle::RcsFunctionalities]
43
+ # @example
44
+ # api = Pinnacle::Client.new(
45
+ # base_url: "https://api.example.com",
46
+ # environment: Pinnacle::Environment::DEFAULT,
47
+ # api_key: "YOUR_API_KEY"
48
+ # )
49
+ # api.get_rcs_functionality
50
+ def get_rcs_functionality(phone_number: nil, request_options: nil)
51
+ response = @request_client.conn.get do |req|
52
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
53
+ req.headers["PINNACLE-API-Key"] = request_options.api_key unless request_options&.api_key.nil?
54
+ req.headers = {
55
+ **(req.headers || {}),
56
+ **@request_client.get_headers,
57
+ **(request_options&.additional_headers || {})
58
+ }.compact
59
+ req.params = { **(request_options&.additional_query_parameters || {}), "phoneNumber": phone_number }.compact
60
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
61
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
62
+ end
63
+ req.url "#{@request_client.get_url(request_options: request_options)}/rcs_functionality"
64
+ end
65
+ Pinnacle::RcsFunctionalities.from_json(json_object: response.body)
66
+ end
67
+ end
68
+
69
+ class AsyncClient
70
+ # @return [Pinnacle::AsyncCompanyClient]
71
+ attr_reader :company
72
+ # @return [Pinnacle::AsyncSendClient]
73
+ attr_reader :send
74
+
75
+ # @param base_url [String]
76
+ # @param environment [Pinnacle::Environment]
77
+ # @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
78
+ # @param timeout_in_seconds [Long]
79
+ # @param api_key [String]
80
+ # @return [Pinnacle::AsyncClient]
81
+ def initialize(api_key:, base_url: nil, environment: Pinnacle::Environment::DEFAULT, max_retries: nil,
82
+ timeout_in_seconds: nil)
83
+ @async_request_client = Pinnacle::AsyncRequestClient.new(
84
+ base_url: base_url,
85
+ environment: environment,
86
+ max_retries: max_retries,
87
+ timeout_in_seconds: timeout_in_seconds,
88
+ api_key: api_key
89
+ )
90
+ @company = Pinnacle::AsyncCompanyClient.new(request_client: @async_request_client)
91
+ @send = Pinnacle::AsyncSendClient.new(request_client: @async_request_client)
92
+ end
93
+
94
+ # Retrieve the RCS functionality of a phone number. For example checks if a phone
95
+ # number can receive RCS message and if it can receive RCS carousels.
96
+ #
97
+ # @param phone_number [String] The phone number to check for RCS functionality. Should be in E.164 format (i.e.
98
+ # +12345678901).
99
+ # @param request_options [Pinnacle::RequestOptions]
100
+ # @return [Pinnacle::RcsFunctionalities]
101
+ # @example
102
+ # api = Pinnacle::Client.new(
103
+ # base_url: "https://api.example.com",
104
+ # environment: Pinnacle::Environment::DEFAULT,
105
+ # api_key: "YOUR_API_KEY"
106
+ # )
107
+ # api.get_rcs_functionality
108
+ def get_rcs_functionality(phone_number: nil, request_options: nil)
109
+ response = @async_request_client.conn.get do |req|
110
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
111
+ req.headers["PINNACLE-API-Key"] = request_options.api_key unless request_options&.api_key.nil?
112
+ req.headers = {
113
+ **(req.headers || {}),
114
+ **@async_request_client.get_headers,
115
+ **(request_options&.additional_headers || {})
116
+ }.compact
117
+ req.params = { **(request_options&.additional_query_parameters || {}), "phoneNumber": phone_number }.compact
118
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
119
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
120
+ end
121
+ req.url "#{@async_request_client.get_url(request_options: request_options)}/rcs_functionality"
122
+ end
123
+ Pinnacle::RcsFunctionalities.from_json(json_object: response.body)
124
+ end
125
+ end
126
+ end
data/lib/requests.rb ADDED
@@ -0,0 +1,163 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "environment"
4
+ require "faraday"
5
+ require "faraday/retry"
6
+ require "async/http/faraday"
7
+
8
+ module Pinnacle
9
+ class RequestClient
10
+ # @return [Faraday]
11
+ attr_reader :conn
12
+ # @return [String]
13
+ attr_reader :base_url
14
+ # @return [String]
15
+ attr_reader :api_key
16
+ # @return [String]
17
+ attr_reader :default_environment
18
+
19
+ # @param base_url [String]
20
+ # @param environment [Pinnacle::Environment]
21
+ # @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
22
+ # @param timeout_in_seconds [Long]
23
+ # @param api_key [String]
24
+ # @return [Pinnacle::RequestClient]
25
+ def initialize(api_key:, base_url: nil, environment: Pinnacle::Environment::DEFAULT, max_retries: nil,
26
+ timeout_in_seconds: nil)
27
+ @default_environment = environment
28
+ @base_url = environment || base_url
29
+ @api_key = api_key
30
+ @conn = Faraday.new do |faraday|
31
+ faraday.request :json
32
+ faraday.response :raise_error, include_request: true
33
+ faraday.request :retry, { max: max_retries } unless max_retries.nil?
34
+ faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil?
35
+ end
36
+ end
37
+
38
+ # @param request_options [Pinnacle::RequestOptions]
39
+ # @return [String]
40
+ def get_url(request_options: nil)
41
+ request_options&.base_url || @default_environment || @base_url
42
+ end
43
+
44
+ # @return [Hash{String => String}]
45
+ def get_headers
46
+ headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "rcs", "X-Fern-SDK-Version": "1.0.10" }
47
+ headers["PINNACLE-API-Key"] = ((@api_key.is_a? Method) ? @api_key.call : @api_key) unless @api_key.nil?
48
+ headers
49
+ end
50
+ end
51
+
52
+ class AsyncRequestClient
53
+ # @return [Faraday]
54
+ attr_reader :conn
55
+ # @return [String]
56
+ attr_reader :base_url
57
+ # @return [String]
58
+ attr_reader :api_key
59
+ # @return [String]
60
+ attr_reader :default_environment
61
+
62
+ # @param base_url [String]
63
+ # @param environment [Pinnacle::Environment]
64
+ # @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
65
+ # @param timeout_in_seconds [Long]
66
+ # @param api_key [String]
67
+ # @return [Pinnacle::AsyncRequestClient]
68
+ def initialize(api_key:, base_url: nil, environment: Pinnacle::Environment::DEFAULT, max_retries: nil,
69
+ timeout_in_seconds: nil)
70
+ @default_environment = environment
71
+ @base_url = environment || base_url
72
+ @api_key = api_key
73
+ @conn = Faraday.new do |faraday|
74
+ faraday.request :json
75
+ faraday.response :raise_error, include_request: true
76
+ faraday.adapter :async_http
77
+ faraday.request :retry, { max: max_retries } unless max_retries.nil?
78
+ faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil?
79
+ end
80
+ end
81
+
82
+ # @param request_options [Pinnacle::RequestOptions]
83
+ # @return [String]
84
+ def get_url(request_options: nil)
85
+ request_options&.base_url || @default_environment || @base_url
86
+ end
87
+
88
+ # @return [Hash{String => String}]
89
+ def get_headers
90
+ headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "rcs", "X-Fern-SDK-Version": "1.0.10" }
91
+ headers["PINNACLE-API-Key"] = ((@api_key.is_a? Method) ? @api_key.call : @api_key) unless @api_key.nil?
92
+ headers
93
+ end
94
+ end
95
+
96
+ # Additional options for request-specific configuration when calling APIs via the
97
+ # SDK.
98
+ class RequestOptions
99
+ # @return [String]
100
+ attr_reader :base_url
101
+ # @return [String]
102
+ attr_reader :api_key
103
+ # @return [Hash{String => Object}]
104
+ attr_reader :additional_headers
105
+ # @return [Hash{String => Object}]
106
+ attr_reader :additional_query_parameters
107
+ # @return [Hash{String => Object}]
108
+ attr_reader :additional_body_parameters
109
+ # @return [Long]
110
+ attr_reader :timeout_in_seconds
111
+
112
+ # @param base_url [String]
113
+ # @param api_key [String]
114
+ # @param additional_headers [Hash{String => Object}]
115
+ # @param additional_query_parameters [Hash{String => Object}]
116
+ # @param additional_body_parameters [Hash{String => Object}]
117
+ # @param timeout_in_seconds [Long]
118
+ # @return [Pinnacle::RequestOptions]
119
+ def initialize(base_url: nil, api_key: nil, additional_headers: nil, additional_query_parameters: nil,
120
+ additional_body_parameters: nil, timeout_in_seconds: nil)
121
+ @base_url = base_url
122
+ @api_key = api_key
123
+ @additional_headers = additional_headers
124
+ @additional_query_parameters = additional_query_parameters
125
+ @additional_body_parameters = additional_body_parameters
126
+ @timeout_in_seconds = timeout_in_seconds
127
+ end
128
+ end
129
+
130
+ # Additional options for request-specific configuration when calling APIs via the
131
+ # SDK.
132
+ class IdempotencyRequestOptions
133
+ # @return [String]
134
+ attr_reader :base_url
135
+ # @return [String]
136
+ attr_reader :api_key
137
+ # @return [Hash{String => Object}]
138
+ attr_reader :additional_headers
139
+ # @return [Hash{String => Object}]
140
+ attr_reader :additional_query_parameters
141
+ # @return [Hash{String => Object}]
142
+ attr_reader :additional_body_parameters
143
+ # @return [Long]
144
+ attr_reader :timeout_in_seconds
145
+
146
+ # @param base_url [String]
147
+ # @param api_key [String]
148
+ # @param additional_headers [Hash{String => Object}]
149
+ # @param additional_query_parameters [Hash{String => Object}]
150
+ # @param additional_body_parameters [Hash{String => Object}]
151
+ # @param timeout_in_seconds [Long]
152
+ # @return [Pinnacle::IdempotencyRequestOptions]
153
+ def initialize(base_url: nil, api_key: nil, additional_headers: nil, additional_query_parameters: nil,
154
+ additional_body_parameters: nil, timeout_in_seconds: nil)
155
+ @base_url = base_url
156
+ @api_key = api_key
157
+ @additional_headers = additional_headers
158
+ @additional_query_parameters = additional_query_parameters
159
+ @additional_body_parameters = additional_body_parameters
160
+ @timeout_in_seconds = timeout_in_seconds
161
+ end
162
+ end
163
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rcs/company/types/company_register_response_brand"
4
+ require_relative "rcs/company/types/company_register_response"
5
+ require_relative "rcs/company/types/company_update_response_brand"
6
+ require_relative "rcs/company/types/company_update_response"
7
+ require_relative "rcs/send/types/send_rcs_response"
8
+ require_relative "rcs/send/types/send_sms_response"
9
+ require_relative "rcs/send/types/send_mms_response"
10
+ require_relative "rcs/types/bad_request_error_body"
11
+ require_relative "rcs/types/unauthorized_error_body"
12
+ require_relative "rcs/types/internal_server_error_body"
13
+ require_relative "rcs/types/forbidden_error_body"
14
+ require_relative "rcs/types/rcs_functionalities"
15
+ require_relative "rcs/types/company_additional_websites_item"
16
+ require_relative "rcs/types/company_additional_emails_item"
17
+ require_relative "rcs/types/company_additional_phone_numbers_item"
18
+ require_relative "rcs/types/company"
19
+ require_relative "rcs/types/company_details"
20
+ require_relative "rcs/types/company_contact"
21
+ require_relative "rcs/types/point_of_contact"
22
+ require_relative "rcs/types/additional_website"
23
+ require_relative "rcs/types/additional_phone_number"
24
+ require_relative "rcs/types/additional_email"
25
+ require_relative "rcs/types/optionals"
26
+ require_relative "rcs/types/card"
27
+ require_relative "rcs/types/action_type"
28
+ require_relative "rcs/types/action_lat_long"
29
+ require_relative "rcs/types/action"
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rcs
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.10
5
+ platform: ruby
6
+ authors:
7
+ - ''
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-10-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: async-http-faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: faraday
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '1.10'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '3.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '1.10'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '3.0'
53
+ - !ruby/object:Gem::Dependency
54
+ name: faraday-net_http
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '1.0'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '4.0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '1.0'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '4.0'
73
+ - !ruby/object:Gem::Dependency
74
+ name: faraday-retry
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '1.0'
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: '3.0'
93
+ description: ''
94
+ email: ''
95
+ executables: []
96
+ extensions: []
97
+ extra_rdoc_files: []
98
+ files:
99
+ - lib/environment.rb
100
+ - lib/gemconfig.rb
101
+ - lib/rcs.rb
102
+ - lib/rcs/company/client.rb
103
+ - lib/rcs/company/types/company_register_response.rb
104
+ - lib/rcs/company/types/company_register_response_brand.rb
105
+ - lib/rcs/company/types/company_update_response.rb
106
+ - lib/rcs/company/types/company_update_response_brand.rb
107
+ - lib/rcs/send/client.rb
108
+ - lib/rcs/send/types/send_mms_response.rb
109
+ - lib/rcs/send/types/send_rcs_response.rb
110
+ - lib/rcs/send/types/send_sms_response.rb
111
+ - lib/rcs/types/action.rb
112
+ - lib/rcs/types/action_lat_long.rb
113
+ - lib/rcs/types/action_type.rb
114
+ - lib/rcs/types/additional_email.rb
115
+ - lib/rcs/types/additional_phone_number.rb
116
+ - lib/rcs/types/additional_website.rb
117
+ - lib/rcs/types/bad_request_error_body.rb
118
+ - lib/rcs/types/card.rb
119
+ - lib/rcs/types/company.rb
120
+ - lib/rcs/types/company_additional_emails_item.rb
121
+ - lib/rcs/types/company_additional_phone_numbers_item.rb
122
+ - lib/rcs/types/company_additional_websites_item.rb
123
+ - lib/rcs/types/company_contact.rb
124
+ - lib/rcs/types/company_details.rb
125
+ - lib/rcs/types/forbidden_error_body.rb
126
+ - lib/rcs/types/internal_server_error_body.rb
127
+ - lib/rcs/types/optionals.rb
128
+ - lib/rcs/types/point_of_contact.rb
129
+ - lib/rcs/types/rcs_functionalities.rb
130
+ - lib/rcs/types/unauthorized_error_body.rb
131
+ - lib/requests.rb
132
+ - lib/types_export.rb
133
+ homepage: https://github.com/pinnacle-dev/rcs-ruby
134
+ licenses: []
135
+ metadata:
136
+ homepage_uri: https://github.com/pinnacle-dev/rcs-ruby
137
+ source_code_uri: https://github.com/pinnacle-dev/rcs-ruby
138
+ changelog_uri: https://github.com/pinnacle-dev/rcs-ruby/blob/master/CHANGELOG.md
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: 2.7.0
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubygems_version: 3.1.6
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: ''
158
+ test_files: []