Sha256: 570ba506528235e16ff9ecdccb4f7c52c2e53d3cce814481bd04adce9ad9ed6e

Contents?: true

Size: 798 Bytes

Versions: 2

Compression:

Stored size: 798 Bytes

Contents

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

module SendGrid4r::REST
  #
  # SendGrid Web API v3 Categories
  #
  module Categories
    include Request

    Category = Struct.new(:category)

    def self.create_category(resp)
      return resp if resp.nil?
      Category.new(resp['category'])
    end

    def self.create_categories(resp)
      return resp if resp.nil?
      resp.map { |category| Categories.create_category(category) }
    end

    def get_categories(category: nil, limit: nil, offset: nil, &block)
      params = {}
      params['category'] = category unless category.nil?
      params['limit'] = limit unless limit.nil?
      params['offset'] = offset unless limit.nil?
      resp = get(@auth, "#{BASE_URL}/categories", params, &block)
      Categories.create_categories(resp)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sendgrid4r-1.11.0 lib/sendgrid4r/rest/categories.rb
sendgrid4r-1.10.0 lib/sendgrid4r/rest/categories.rb