Class: Payabli::Notification::Client
- Inherits:
-
Object
- Object
- Payabli::Notification::Client
- Defined in:
- lib/payabli/notification/client.rb
Instance Method Summary collapse
-
#add_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Create a new notification or auto-generated report.
-
#delete_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Deletes a single notification or auto-generated report.
-
#get_notification(request_options: {}, **params) ⇒ Payabli::Types::NotificationQueryRecord
Retrieves a single notification or auto-generated report's details.
-
#get_report_file(request_options: {}, **params) ⇒ Hash[String, Object]
Gets a copy of a generated report by ID.
- #initialize(client:) ⇒ void constructor
-
#update_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Update a notification or auto-generated report.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/payabli/notification/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#add_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Create a new notification or auto-generated report.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/payabli/notification/client.rb', line 37 def add_notification(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "Notification", headers: headers, body: Payabli::Types::AddNotificationRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseNotifications.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Deletes a single notification or auto-generated report.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/payabli/notification/client.rb', line 167 def delete_notification(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "Notification/#{URI.encode_uri_component(params[:n_id].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseNotifications.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_notification(request_options: {}, **params) ⇒ Payabli::Types::NotificationQueryRecord
Retrieves a single notification or auto-generated report's details.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/payabli/notification/client.rb', line 77 def get_notification(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Notification/#{URI.encode_uri_component(params[:n_id].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::NotificationQueryRecord.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_report_file(request_options: {}, **params) ⇒ Hash[String, Object]
Gets a copy of a generated report by ID.
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/payabli/notification/client.rb', line 206 def get_report_file(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Export/notificationReport/#{URI.encode_uri_component(params[:id].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::File.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Update a notification or auto-generated report.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/payabli/notification/client.rb', line 127 def update_notification(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "Notification/#{URI.encode_uri_component(params[:n_id].to_s)}", headers: headers, body: Payabli::Types::UpdateNotificationRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseNotifications.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |