lib/sendgrid4r/rest/ips/warmup.rb in sendgrid4r-1.8.1 vs lib/sendgrid4r/rest/ips/warmup.rb in sendgrid4r-1.10.0
- old
+ new
@@ -1,61 +1,52 @@
# -*- encoding: utf-8 -*-
-module SendGrid4r
- module REST
- module Ips
- #
- # SendGrid Web API v3 Ip Management - Warmup
- #
- module Warmup
- include SendGrid4r::REST::Request
+module SendGrid4r::REST
+ module Ips
+ #
+ # SendGrid Web API v3 Ip Management - Warmup
+ #
+ module Warmup
+ include Request
- WarmupIp = Struct.new(:ip, :start_date)
+ WarmupIp = Struct.new(:ip, :start_date)
- def self.create_warmup_ips(resp)
- return resp if resp.nil?
- ips = []
- resp.each do |warmup_ip|
- ips.push(SendGrid4r::REST::Ips::Warmup.create_warmup_ip(warmup_ip))
- end
- ips
- end
+ def self.create_warmup_ips(resp)
+ return resp if resp.nil?
+ resp.map { |warmup_ip| Ips::Warmup.create_warmup_ip(warmup_ip) }
+ end
- def self.create_warmup_ip(resp)
- return resp if resp.nil?
- WarmupIp.new(
- resp['ip'],
- resp['start_date'].nil? ? nil : Time.at(resp['start_date'])
- )
- end
+ def self.create_warmup_ip(resp)
+ return resp if resp.nil?
+ WarmupIp.new(
+ resp['ip'],
+ resp['start_date'].nil? ? nil : Time.at(resp['start_date'])
+ )
+ end
- def self.url(ip_address = nil)
- url = "#{BASE_URL}/ips/warmup"
- url = "#{url}/#{ip_address}" unless ip_address.nil?
- url
- end
+ def self.url(ip_address = nil)
+ url = "#{BASE_URL}/ips/warmup"
+ url = "#{url}/#{ip_address}" unless ip_address.nil?
+ url
+ end
- def get_warmup_ips(&block)
- resp = get(@auth, SendGrid4r::REST::Ips::Warmup.url, &block)
- SendGrid4r::REST::Ips::Warmup.create_warmup_ips(resp)
- end
+ def get_warmup_ips(&block)
+ resp = get(@auth, Ips::Warmup.url, &block)
+ Ips::Warmup.create_warmup_ips(resp)
+ end
- def get_warmup_ip(ip:, &block)
- endpoint = SendGrid4r::REST::Ips::Warmup.url(ip)
- resp = get(@auth, endpoint, &block)
- SendGrid4r::REST::Ips::Warmup.create_warmup_ip(resp)
- end
+ def get_warmup_ip(ip:, &block)
+ resp = get(@auth, Ips::Warmup.url(ip), &block)
+ Ips::Warmup.create_warmup_ip(resp)
+ end
- def post_warmup_ip(ip:, &block)
- endpoint = SendGrid4r::REST::Ips::Warmup.url
- resp = post(@auth, endpoint, ip: ip, &block)
- SendGrid4r::REST::Ips::Warmup.create_warmup_ip(resp)
- end
+ def post_warmup_ip(ip:, &block)
+ resp = post(@auth, Ips::Warmup.url, ip: ip, &block)
+ Ips::Warmup.create_warmup_ip(resp)
+ end
- def delete_warmup_ip(ip:, &block)
- endpoint = SendGrid4r::REST::Ips::Warmup.url(ip)
- delete(@auth, endpoint, &block)
- end
+ def delete_warmup_ip(ip:, &block)
+ delete(@auth, Ips::Warmup.url(ip), &block)
end
end
end
end