Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Adding examples for the new marketing campaigns #476

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .codeclimate.yml

This file was deleted.

115 changes: 115 additions & 0 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Test and Deploy
on:
push:
branches: [ '*' ]
tags: [ '*' ]
pull_request:
branches: [ main ]
schedule:
# Run automatically at 8AM PST Monday-Friday
- cron: '0 15 * * 1-5'
workflow_dispatch:

jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', 'jruby-9.2' ]
env:
version: ${{ format('ruby:{0}', matrix.ruby) }}
DOCKER_LOGIN: ${{ secrets.DOCKER_USERNAME && secrets.DOCKER_AUTH_TOKEN }}
steps:
- name: Revise env version if necessary
run: echo "version=jruby:9.2" >> $GITHUB_ENV
if: ${{ matrix.ruby == 'jruby-9.2' }}

- name: Checkout sendgrid-ruby
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Login to Docker Hub
if: env.DOCKER_LOGIN
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_AUTH_TOKEN }}

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- run: make install

- name: Set up linter
run: bundle add rubocop --version "~> 1.24.1" --group "development" --skip-install
if: ${{ matrix.ruby != '2.4' }}

- run: bundle install --with development

- name: Run linter
run: bundle exec rubocop
if: ${{ matrix.ruby != '2.4' }}

- name: Run tests
run: make test-docker

deploy:
name: Deploy
if: success() && github.ref_type == 'tag'
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Checkout sendgrid-ruby
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true

- run: make install

- name: Create GitHub Release
uses: sendgrid/dx-automator/actions/release@main
with:
footer: '**[RubyGems](https://rubygems.org/gems/sendgrid-ruby/versions/${version})**'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to Rubygems
env:
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem

notify-on-failure:
name: Slack notify on failure
if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
needs: [ test, deploy ]
runs-on: ubuntu-latest
steps:
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: failure
SLACK_ICON_EMOJI: ':github:'
SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }}
SLACK_TITLE: Action Failure - ${{ github.repository }}
SLACK_USERNAME: GitHub Actions
SLACK_MSG_AUTHOR: twilio-dx
SLACK_FOOTER: Posted automatically using GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: true
66 changes: 41 additions & 25 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,57 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-09-18 20:20:54 UTC using RuboCop version 0.91.0.
# on 2022-01-25 23:45:43 UTC using RuboCop version 1.22.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
Bundler/OrderedGems:
Exclude:
- 'Gemfile'

# Offense count: 1
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'sendgrid-ruby.gemspec'

# Offense count: 22
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingEmptyLines:
Exclude:
- 'Gemfile'

# Offense count: 24
Lint/UselessAssignment:
Exclude:
- 'examples/scopes/scopes.rb'
- 'spec/rack/sendgrid_webhook_verification_spec.rb'

# Offense count: 8
# Configuration parameters: IgnoredMethods.
# Offense count: 10
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 144

# Offense count: 9
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 96
Max: 134

# Offense count: 3
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 2006
Exclude:
- 'test/sendgrid/test_sendgrid-ruby.rb'
Max: 2018

# Offense count: 41
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
# Offense count: 45
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 141

# Offense count: 2
# Configuration parameters: CountKeywordArgs.
# Offense count: 4
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 7

Expand Down Expand Up @@ -76,15 +84,15 @@ Naming/PredicateName:
- 'examples/helpers/eventwebhook/example.rb'

# Offense count: 35
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false

# Offense count: 4
# Configuration parameters: EnforcedStyle.
# Offense count: 3
# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, IgnoredMethods.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
Exclude:
- 'examples/emailactivity/emailactivity.rb'
EnforcedStyle: unannotated

# Offense count: 97
# Cop supports --auto-correct.
Expand All @@ -93,6 +101,14 @@ Style/FormatStringToken:
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Exclude:
- 'Gemfile'

# Offense count: 6
Style/MixinUsage:
Exclude:
Expand All @@ -103,9 +119,9 @@ Style/MixinUsage:
- 'test/sendgrid/helpers/mail/test_attachment.rb'
- 'test/sendgrid/helpers/mail/test_mail.rb'

# Offense count: 55
# Offense count: 54
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 3211
Max: 381
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Change Log
All notable changes to this project will be documented in this file.

[2022-02-09] Version 6.6.1
--------------------------
**Library - Chore**
- [PR #482](https://github.com/sendgrid/sendgrid-ruby/pull/482): upgrade supported language versions. Thanks to [@childish-sambino](https://github.com/childish-sambino)!
- [PR #480](https://github.com/sendgrid/sendgrid-ruby/pull/480): add gh release to workflow. Thanks to [@shwetha-manvinkurke](https://github.com/shwetha-manvinkurke)!
- [PR #478](https://github.com/sendgrid/sendgrid-ruby/pull/478): migrate to gh actions. Thanks to [@beebzz](https://github.com/beebzz)!

**Library - Fix**
- [PR #479](https://github.com/sendgrid/sendgrid-ruby/pull/479): set version env var for tests. Thanks to [@beebzz](https://github.com/beebzz)!


[2021-11-03] Version 6.6.0
--------------------------
**Library - Feature**
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (C) 2021, Twilio SendGrid, Inc. <help@twilio.com>
Copyright (C) 2022, Twilio SendGrid, Inc. <help@twilio.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ install:

test:
bundle exec rake
rubocop

test-integ: test

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Twilio SendGrid Logo](twilio_sendgrid_logo.png)

[![Travis Badge](https://travis-ci.com/sendgrid/sendgrid-ruby.svg?branch=main)](https://travis-ci.com/sendgrid/sendgrid-ruby)
[![Travis Badge](https://github.com/sendgrid/sendgrid-ruby/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/sendgrid/sendgrid-ruby/actions/workflows/test-and-deploy.yml)
[![Gem Version](https://badge.fury.io/rb/sendgrid-ruby.svg)](https://badge.fury.io/rb/sendgrid-ruby)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
Expand Down
29 changes: 29 additions & 0 deletions examples/new_marketing_campaigns/contacts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'sendgrid-ruby'

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

##################################################
# Add or Update a Contact #
# POST /marketing/contacts #

data = JSON.parse('{
"list_ids": [
"ca7a3796-e8a8-4029-9ccb-df8937940562"
],
"contacts": [
{
"address_line_1": "123 Elm St.",
"address_line_2": "Apt. 456",
"city": "Denver",
"country": "United States",
"email": "example@example.com",
"first_name": "User",
"last_name": "Example"
}
]
}')

response = sg.client.marketing.contacts.put(request_body: data)
puts response.status_code
puts response.body
puts response.headers
Loading