lib/sendgrid4r/rest/contacts/reserved_fields.rb in sendgrid4r-0.2.0 vs lib/sendgrid4r/rest/contacts/reserved_fields.rb in sendgrid4r-0.3.0

- old
+ new

@@ -23,25 +23,29 @@ end Fields = Struct.new(:reserved_fields) def self.create_fields(resp) + return resp if resp.nil? reserved_fields = [] resp['reserved_fields'].each do |field| reserved_fields.push( SendGrid4r::REST::Contacts::ReservedFields.create_field(field) ) end Fields.new(reserved_fields) end def self.create_field(resp) + return resp if resp.nil? Field.new(resp['name'], resp['type']) end - def get_reserved_fields + def get_reserved_fields(&block) resp = get( - @auth, "#{SendGrid4r::Client::BASE_URL}/contactdb/reserved_fields" + @auth, + "#{SendGrid4r::Client::BASE_URL}/contactdb/reserved_fields", + &block ) SendGrid4r::REST::Contacts::ReservedFields.create_fields(resp) end end end