Sha256: b4b6003706751e3acd63b3ca7a3b41f8bd9e6f7e4a78f5d571f05c92f5b75407

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

# -*- encoding: utf-8 -*-

module SendGrid4r::REST
  module MarketingCampaigns
    module Contacts
      #
      # SendGrid Web API v3 Contacts - Reserved Fields
      #
      module ReservedFields
        include Request

        Field = Struct.new(:name, :type) do
          def eql?(other)
            name.eql?(other.name)
          end

          def hash
            name.hash
          end
        end

        Fields = Struct.new(:reserved_fields)

        def self.create_fields(resp)
          return resp if resp.nil?
          reserved_fields = resp['reserved_fields'].map do |field|
            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(&block)
          resp = get(@auth, "#{BASE_URL}/contactdb/reserved_fields", &block)
          finish(resp, @raw_resp) do |r|
            Contacts::ReservedFields.create_fields(r)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sendgrid4r-1.15.0 lib/sendgrid4r/rest/marketing_campaigns/contacts/reserved_fields.rb
sendgrid4r-1.14.0 lib/sendgrid4r/rest/marketing_campaigns/contacts/reserved_fields.rb
sendgrid4r-1.13.0 lib/sendgrid4r/rest/marketing_campaigns/contacts/reserved_fields.rb
sendgrid4r-1.12.0 lib/sendgrid4r/rest/marketing_campaigns/contacts/reserved_fields.rb