Class: Payabli::Notificationlogs::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/payabli/notificationlogs/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



9
10
11
# File 'lib/payabli/notificationlogs/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#bulk_retry_notification_logs(request_options: {}, **params) ⇒ untyped

Retry sending multiple notifications (maximum 50 IDs). This is an async process, so use the search endpoint again to check the notification status.

This endpoint requires the ‘notifications_create` permission.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:

  • (untyped)

Raises:

  • (error_class)


143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/payabli/notificationlogs/client.rb', line 143

def bulk_retry_notification_logs(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "/v2/notificationlogs/retry",
    body: params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  return if code.between?(200, 299)

  error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(response.body, code: code)
end

#get_notification_log(request_options: {}, **params) ⇒ Payabli::Notificationlogs::Types::NotificationLogDetail

Get detailed information for a specific notification log entry. This endpoint requires the ‘notifications_create` OR `notifications_read` permission.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :uuid (String)

Returns:



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/payabli/notificationlogs/client.rb', line 71

def get_notification_log(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "/v2/notificationlogs/#{URI.encode_uri_component(params[:uuid].to_s)}",
    request_options: 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::Notificationlogs::Types::NotificationLogDetail.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#retry_notification_log(request_options: {}, **params) ⇒ Payabli::Notificationlogs::Types::NotificationLogDetail

Retry sending a specific notification.

Permissions: notifications_create

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :uuid (String)

Returns:



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/payabli/notificationlogs/client.rb', line 107

def retry_notification_log(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "/v2/notificationlogs/#{URI.encode_uri_component(params[:uuid].to_s)}/retry",
    request_options: 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::Notificationlogs::Types::NotificationLogDetail.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#search_notification_logs(request_options: {}, **params) ⇒ Array[Payabli::Notificationlogs::Types::NotificationLog]

Search notification logs with filtering and pagination.

- Start date and end date cannot be more than 30 days apart
- Either `orgId` or `paypointId` must be provided

This endpoint requires the ‘notifications_create` OR `notifications_read` permission.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :page_size (Integer, nil)
  • :page (Integer, nil)

Returns:

Raises:

  • (error_class)


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/payabli/notificationlogs/client.rb', line 30

def search_notification_logs(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[page_size page]
  query_params = {}
  query_params["PageSize"] = params[:page_size] if params.key?(:page_size)
  query_params["Page"] = params[:page] if params.key?(:page)
  params = params.except(*query_param_names)

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "/v2/notificationlogs",
    query: query_params,
    body: Payabli::Notificationlogs::Types::NotificationLogSearchRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  return if code.between?(200, 299)

  error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(response.body, code: code)
end