Class: Resend::Client
- Inherits:
-
Object
- Object
- Resend::Client
- Defined in:
- lib/resend/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.klotty.com/".freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize(api_key) ⇒ Client
constructor
A new instance of Client.
- #send_email(params) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 |
# File 'lib/resend/client.rb', line 12 def initialize(api_key) raise ArgumentError.new("API Key is not a string") unless api_key.is_a?(String) @api_key = api_key @timeout = nil end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/resend/client.rb', line 10 def api_key @api_key end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
10 11 12 |
# File 'lib/resend/client.rb', line 10 def base_url @base_url end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
10 11 12 |
# File 'lib/resend/client.rb', line 10 def timeout @timeout end |
Instance Method Details
#send_email(params) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/resend/client.rb', line 18 def send_email(params) validate!(params) = { headers: { 'Content-Type' => 'application/json', "Accept" => "application/json", "User-Agent" => "ruby:#{Resend::VERSION}", "Authorization" => "Bearer #{@api_key}", }, body: params.to_json } resp = HTTParty.post("#{BASE_URL}/email", ) resp.transform_keys!(&:to_sym) if not resp[:error].nil? handle_error!(resp[:error]) end resp end |