Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add prefix to API_URL and API_BASE_HOST constant name #76

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [Released]

## [2.0.2] - 2024-03-12

- Update constant name

## [2.0.1] - 2023-01-08

- Simple personalization removed
Expand Down
2 changes: 1 addition & 1 deletion lib/mailersend/activity/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get(domain_id:, page: nil, limit: nil, date_from: nil, date_to: nil)
date_to: date_to
}

client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/activity/#{domain_id}",
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/activity/#{domain_id}",
query: URI.encode_www_form(hash.compact)))
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/mailersend/analytics/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def date(date_from:, date_to:, events:, domain_id: nil, recipient_id: nil, group
'tags[]' => tags
}

client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/date',
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/analytics/date',
query: URI.encode_www_form(hash.compact)))
end

Expand All @@ -47,7 +47,7 @@ def country(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil)
'tags[]': tags
}

client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/country',
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/analytics/country',
query: URI.encode_www_form(hash.compact)))
end

Expand All @@ -60,7 +60,7 @@ def ua_name(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil)
'tags[]': tags
}

client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/ua-name',
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/analytics/ua-name',
query: URI.encode_www_form(hash.compact)))
end

Expand All @@ -73,7 +73,7 @@ def ua_type(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil)
'tags[]': tags
}

client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/ua-type',
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/analytics/ua-type',
query: URI.encode_www_form(hash.compact)))
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mailersend/api_quota/api_quota.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(client = Mailersend::Client.new)
end

def get_api_quota(*)
client.http.get("#{API_URL}/api-quota")
client.http.get("#{MAILERSEND_API_URL}/api-quota")
end
end
end
4 changes: 2 additions & 2 deletions lib/mailersend/bulk_email/bulk_email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def add_attachment(content:, filename:, disposition:)
end

def send
client.http.post("#{API_URL}/bulk-email", json: @messages)
client.http.post("#{MAILERSEND_API_URL}/bulk-email", json: @messages)
end

def get_bulk_status(bulk_email_id:)
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/bulk-email/#{bulk_email_id}"))
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/bulk-email/#{bulk_email_id}"))
end
end
end
4 changes: 2 additions & 2 deletions lib/mailersend/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

require 'http'

API_URL = 'https://api.mailersend.com/v1'
API_BASE_HOST = 'api.mailersend.com'
MAILERSEND_API_URL = 'https://api.mailersend.com/v1'
MAILERSEND_API_BASE_HOST = 'api.mailersend.com'

# mailersend-ruby is a gem that integrates all endpoints from MailerSend API
module Mailersend
Expand Down
16 changes: 8 additions & 8 deletions lib/mailersend/domains/domains.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def list(page: nil, limit: nil, verified: nil)
'limit' => limit,
'verified' => verified
}
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/domains',
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/domains',
query: URI.encode_www_form(hash.compact)))
end

Expand All @@ -35,7 +35,7 @@ def single(domain_id:, page: nil, limit: nil, verified: nil)
'limit' => limit,
'verified' => verified
}
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}",
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/domains/#{domain_id}",
query: URI.encode_www_form(hash.compact)))
end

Expand All @@ -46,19 +46,19 @@ def add(name: nil, return_path_subdomain: nil, custom_tracking_subdomain: nil, i
'custom_tracking_subdomain' => custom_tracking_subdomain,
'inbound_routing_subdomain' => inbound_routing_subdomain
}
client.http.post("#{API_URL}/domains", json: hash.compact)
client.http.post("#{MAILERSEND_API_URL}/domains", json: hash.compact)
end

def delete(domain_id:)
client.http.delete(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}"))
client.http.delete(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/domains/#{domain_id}"))
end

def recipients(domain_id:)
hash = {
'page' => page,
'limit' => limit
}
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}/recipients",
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/domains/#{domain_id}/recipients",
query: URI.encode_www_form(hash.compact)))
end

Expand All @@ -75,15 +75,15 @@ def settings(domain_id:, send_paused: nil, track_clicks: nil, track_opens: nil,
'custom_tracking_subdomain' => custom_tracking_subdomain,
'precedence_bulk' => precedence_bulk
}
client.http.put("#{API_URL}/domains/#{domain_id}/settings", json: hash.compact)
client.http.put("#{MAILERSEND_API_URL}/domains/#{domain_id}/settings", json: hash.compact)
end

def dns(domain_id:)
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}/dns-records"))
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/domains/#{domain_id}/dns-records"))
end

def verify(domain_id:)
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}/verify"))
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/domains/#{domain_id}/verify"))
end
end
end
2 changes: 1 addition & 1 deletion lib/mailersend/email/email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def send
'tags' => @tags
}

client.http.post("#{API_URL}/email", json: message.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} })
client.http.post("#{MAILERSEND_API_URL}/email", json: message.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} })
end
end
end
12 changes: 6 additions & 6 deletions lib/mailersend/email_verification/email_verification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,36 @@ def verify_an_email(email: nil)
hash = {
'email' => email
}
client.http.post("#{API_URL}/email-verification/verify", json: hash.compact)
client.http.post("#{MAILERSEND_API_URL}/email-verification/verify", json: hash.compact)
end

def list(page: nil, limit: nil)
hash = {
'page' => page,
'limit' => limit
}
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/email-verification',
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/email-verification',
query: URI.encode_www_form(hash)))
end

def get_single_list(email_verification_id:)
client.http.get("#{API_URL}/email-verification/#{email_verification_id}")
client.http.get("#{MAILERSEND_API_URL}/email-verification/#{email_verification_id}")
end

def create_a_list(name: nil, emails: nil)
hash = {
'name' => name,
'emails' => emails
}
client.http.post("#{API_URL}/email-verification", json: hash.compact)
client.http.post("#{MAILERSEND_API_URL}/email-verification", json: hash.compact)
end

def verify_a_list(email_verification_id:)
client.http.get("#{API_URL}/email-verification/#{email_verification_id}/verify")
client.http.get("#{MAILERSEND_API_URL}/email-verification/#{email_verification_id}/verify")
end

def get_list_results(email_verification_id:)
client.http.get("#{API_URL}/email-verification/#{email_verification_id}/results")
client.http.get("#{MAILERSEND_API_URL}/email-verification/#{email_verification_id}/results")
end
end
end
10 changes: 5 additions & 5 deletions lib/mailersend/inbound_routing/inbound_routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ def initialize(client = Mailersend::Client.new)
end

def get_inbound_routes(*)
client.http.get("#{API_URL}/inbound")
client.http.get("#{MAILERSEND_API_URL}/inbound")
end

def get_single_route(inbound_id:)
client.http.get("#{API_URL}/inbound/#{inbound_id}")
client.http.get("#{MAILERSEND_API_URL}/inbound/#{inbound_id}")
end

def add_inbound_route
client.http.post("#{API_URL}/inbound", json: @settings)
client.http.post("#{MAILERSEND_API_URL}/inbound", json: @settings)
end

def update_inbound_route(inbound_id:)
client.http.put("#{API_URL}/inbound/#{inbound_id}", json: @settings)
client.http.put("#{MAILERSEND_API_URL}/inbound/#{inbound_id}", json: @settings)
end

def delete_route(inbound_id:)
client.http.delete("#{API_URL}/inbound/#{inbound_id}")
client.http.delete("#{MAILERSEND_API_URL}/inbound/#{inbound_id}")
end
end
end
4 changes: 2 additions & 2 deletions lib/mailersend/messages/messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def list(page: nil, limit: nil)
'limit' => limit
}

client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/messages',
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/messages',
query: URI.encode_www_form(hash)))
end

def single(message_id:)
client.http.get("#{API_URL}/messages/#{message_id}")
client.http.get("#{MAILERSEND_API_URL}/messages/#{message_id}")
end
end
end
6 changes: 3 additions & 3 deletions lib/mailersend/recipients/recipients.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ def list(page: nil, limit: nil)
'limit' => limit
}

client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/recipients',
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/recipients',
query: URI.encode_www_form(hash)))
end

def single(recipient_id:)
client.http.get("#{API_URL}/recipients/#{recipient_id}")
client.http.get("#{MAILERSEND_API_URL}/recipients/#{recipient_id}")
end

def delete(recipient_id:)
client.http.delete("#{API_URL}/recipients/#{recipient_id}")
client.http.delete("#{MAILERSEND_API_URL}/recipients/#{recipient_id}")
end
end
end
6 changes: 3 additions & 3 deletions lib/mailersend/scheduled_messages/scheduled_messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ def initialize(client = Mailersend::Client.new)
end

def get_list(*)
client.http.get("#{API_URL}/message-schedules")
client.http.get("#{MAILERSEND_API_URL}/message-schedules")
end

def get_signle(message_id:)
client.http.get("#{API_URL}/message-schedules/#{message_id}")
client.http.get("#{MAILERSEND_API_URL}/message-schedules/#{message_id}")
end

def delete(message_id:)
client.http.delete("#{API_URL}/message-schedules/#{message_id}")
client.http.delete("#{MAILERSEND_API_URL}/message-schedules/#{message_id}")
end
end
end
16 changes: 8 additions & 8 deletions lib/mailersend/sender_identity/sender_identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ def list(domain_id: nil, page: nil, limit: nil)
'page' => page,
'limit' => limit
}
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/identities',
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/identities',
query: URI.encode_www_form(hash.compact)))
end

def single(identity_id:)
hash = {
'identity_id' => identity_id
}
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/identities/#{identity_id}",
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/identities/#{identity_id}",
query: URI.encode_www_form(hash.compact)))
end

def single_by_email(email:)
hash = {
'email' => email
}
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/identities/email/#{email}",
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/identities/email/#{email}",
query: URI.encode_www_form(hash.compact)))
end

Expand All @@ -55,7 +55,7 @@ def add(domain_id: nil, name: nil, email: nil, reply_to_email: nil, reply_to_nam
'add_note' => add_note,
'personal_note' => personal_note
}
client.http.post("#{API_URL}/identities", json: hash.compact)
client.http.post("#{MAILERSEND_API_URL}/identities", json: hash.compact)
end

def update(identity_id:, domain_id: nil, name: nil, email: nil, reply_to_email: nil, reply_to_name: nil, add_note: nil, personal_note: nil)
Expand All @@ -68,7 +68,7 @@ def update(identity_id:, domain_id: nil, name: nil, email: nil, reply_to_email:
'add_note' => add_note,
'personal_note' => personal_note
}
client.http.put("#{API_URL}/identities/#{identity_id}", json: hash.compact)
client.http.put("#{MAILERSEND_API_URL}/identities/#{identity_id}", json: hash.compact)
end

def update_by_email(email:, domain_id: nil, name: nil, reply_to_email: nil, reply_to_name: nil, add_note: nil, personal_note: nil)
Expand All @@ -81,15 +81,15 @@ def update_by_email(email:, domain_id: nil, name: nil, reply_to_email: nil, repl
'add_note' => add_note,
'personal_note' => personal_note
}
client.http.put("#{API_URL}/identities/email/#{email}", json: hash.compact)
client.http.put("#{MAILERSEND_API_URL}/identities/email/#{email}", json: hash.compact)
end

def delete(identity_id:)
client.http.delete(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/identities/#{identity_id}"))
client.http.delete(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/identities/#{identity_id}"))
end

def delete_by_email(email:)
client.http.delete(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/identities/email/#{email}"))
client.http.delete(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/identities/email/#{email}"))
end
end
end
2 changes: 1 addition & 1 deletion lib/mailersend/sms/sms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def send
'personalization' => @personalization
}

response = client.http.post("#{API_URL}/sms", json: message.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} })
response = client.http.post("#{MAILERSEND_API_URL}/sms", json: message.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} })
puts response
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mailersend/sms_activity/sms_activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def list(page: nil, limit: nil)
'limit' => limit
}

client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/sms-activity',
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/sms-activity',
query: URI.encode_www_form(hash)))
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/mailersend/sms_inbounds/sms_inbounds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ def list(page: nil, limit: nil)
'limit' => limit
}

client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/sms-inbounds',
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/sms-inbounds',
query: URI.encode_www_form(hash)))
end

def get_sms_inbound_route(sms_inbound_id:)
client.http.get("#{API_URL}/sms-inbounds/#{sms_inbound_id}")
client.http.get("#{MAILERSEND_API_URL}/sms-inbounds/#{sms_inbound_id}")
end

def add_sms_inbound_route
client.http.post("#{API_URL}/sms-inbounds", json: @settings)
client.http.post("#{MAILERSEND_API_URL}/sms-inbounds", json: @settings)
end

def update_sms_inbound_route(sms_inbound_id:)
client.http.put("#{API_URL}/sms-inbounds/#{sms_inbound_id}", json: @settings)
client.http.put("#{MAILERSEND_API_URL}/sms-inbounds/#{sms_inbound_id}", json: @settings)
end

def delete_sms_inbound_route(sms_inbound_id:)
client.http.delete("#{API_URL}/sms-inbounds/#{sms_inbound_id}")
client.http.delete("#{MAILERSEND_API_URL}/sms-inbounds/#{sms_inbound_id}")
end
end
end
Loading
Loading