-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0766835
commit e70a802
Showing
4 changed files
with
70 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# typed: strict | ||
# frozen_string_literal: true | ||
|
||
require_relative "error_response" | ||
|
||
module WhatsappSdk | ||
module Api | ||
module Responses | ||
class GenericErrorResponse < ErrorResponse | ||
sig { returns(Integer) } | ||
attr_reader :code | ||
|
||
sig { returns(T.nilable(Integer)) } | ||
attr_reader :subcode | ||
|
||
sig { returns(T.nilable(String)) } | ||
attr_reader :message | ||
|
||
sig { returns(T.nilable(String)) } | ||
attr_reader :type | ||
|
||
sig { returns(T.nilable(String)) } | ||
attr_reader :data | ||
|
||
sig { returns(T.nilable(String)) } | ||
attr_reader :fbtrace_id | ||
|
||
sig { params(response: T::Hash[T.untyped, T.untyped]).void } | ||
def initialize(response:) | ||
@code = T.let(response["code"], Integer) | ||
@subcode = T.let(response["error_subcode"], T.nilable(Integer)) | ||
@message = T.let(response["message"], T.nilable(String)) | ||
@type = T.let(response["type"], T.nilable(String)) | ||
@data = T.let(response["data"], T.nilable(String)) | ||
@fbtrace_id = T.let(response["fbtrace_id"], T.nilable(String)) | ||
super(response: response) | ||
end | ||
|
||
sig { override.params(response: T::Hash[T.untyped, T.untyped]).returns(T.nilable(GenericErrorResponse)) } | ||
def self.build_from_response(response:) | ||
error_response = response["error"] | ||
return unless error_response | ||
|
||
new(response: error_response) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters