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 autogenerated report.
-
#delete_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Deletes a single notification or autogenerated report.
-
#get_notification(request_options: {}, **params) ⇒ Payabli::Types::NotificationQueryRecord
Retrieves a single notification or autogenerated 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 autogenerated 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 autogenerated report.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/payabli/notification/client.rb', line 24 def add_notification(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "Notification", body: Payabli::Notification::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 autogenerated report.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/payabli/notification/client.rb', line 59 def delete_notification(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "Notification/#{URI.encode_uri_component(params[:n_id].to_s)}", 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 autogenerated report’s details.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/payabli/notification/client.rb', line 93 def get_notification(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Notification/#{URI.encode_uri_component(params[:n_id].to_s)}", 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.
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/payabli/notification/client.rb', line 162 def get_report_file(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Export/notificationReport/#{URI.encode_uri_component(params[:id].to_s)}", 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 autogenerated report.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/payabli/notification/client.rb', line 127 def update_notification(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "Notification/#{URI.encode_uri_component(params[:n_id].to_s)}", body: Payabli::Notification::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 |