Sha256: b32c398d6c240cad7ef43a6ed5f7b2791552cc44b8bd9fc2f5b3f5a870ad0c18

Contents?: true

Size: 1.27 KB

Versions: 13

Compression:

Stored size: 1.27 KB

Contents

require 'sendgrid-ruby'

sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])

##################################################
# Retrieve all categories #
# GET /categories #

params = JSON.parse('{"category": "test_string", "limit": 1, "offset": 1}')
response = sg.client.categories.get(query_params: params)
puts response.status_code
puts response.body
puts response.headers

##################################################
# Retrieve Email Statistics for Categories #
# GET /categories/stats #

params = JSON.parse('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01", "categories": "test_string"}')
response = sg.client.categories.stats.get(query_params: params)
puts response.status_code
puts response.body
puts response.headers

##################################################
# Retrieve sums of email stats for each category [Needs: Stats object defined, has category ID?] #
# GET /categories/stats/sums #

params = JSON.parse('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "start_date": "2016-01-01", "sort_by_direction": "asc"}')
response = sg.client.categories.stats.sums.get(query_params: params)
puts response.status_code
puts response.body
puts response.headers

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
sendgrid-ruby-6.7.0 examples/categories/categories.rb
sendgrid-ruby-6.6.2 examples/categories/categories.rb
sendgrid-ruby-6.6.1 examples/categories/categories.rb
sendgrid-ruby-6.6.0 examples/categories/categories.rb
sendgrid-ruby-6.5.2 examples/categories/categories.rb
sendgrid-ruby-6.5.1 examples/categories/categories.rb
sendgrid-ruby-6.5.0 examples/categories/categories.rb
sendgrid-ruby-6.4.0 examples/categories/categories.rb
sendgrid-ruby-6.3.9 examples/categories/categories.rb
sendgrid-ruby-6.3.8 examples/categories/categories.rb
sendgrid-ruby-6.3.7 examples/categories/categories.rb
sendgrid-ruby-6.3.6 examples/categories/categories.rb
sendgrid-ruby-6.3.5 examples/categories/categories.rb