Skip to content

Commit e6fad0e

Browse files
committed
Adding examples for the new marketing campaigns
chore: bump license year chore: migrate to gh actions (#478) * chore: migrate to gh actions chore: add gh release to workflow (#480) chore: make Slack message consistent across all repos fix: set version env var for tests (#479) * fix: set ruby version for tests fix: only do a Docker Login if the secrets are available chore: upgrade supported language versions (#482) [Librarian] Version Bump Release 6.6.1
1 parent 54a33bb commit e6fad0e

File tree

15 files changed

+314
-89
lines changed

15 files changed

+314
-89
lines changed

.codeclimate.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Test and Deploy
2+
on:
3+
push:
4+
branches: [ '*' ]
5+
tags: [ '*' ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
# Run automatically at 8AM PST Monday-Friday
10+
- cron: '0 15 * * 1-5'
11+
workflow_dispatch:
12+
13+
jobs:
14+
test:
15+
name: Test
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 20
18+
strategy:
19+
matrix:
20+
ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', 'jruby-9.2' ]
21+
env:
22+
version: ${{ format('ruby:{0}', matrix.ruby) }}
23+
DOCKER_LOGIN: ${{ secrets.DOCKER_USERNAME && secrets.DOCKER_AUTH_TOKEN }}
24+
steps:
25+
- name: Revise env version if necessary
26+
run: echo "version=jruby:9.2" >> $GITHUB_ENV
27+
if: ${{ matrix.ruby == 'jruby-9.2' }}
28+
29+
- name: Checkout sendgrid-ruby
30+
uses: actions/checkout@v2
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Login to Docker Hub
35+
if: env.DOCKER_LOGIN
36+
uses: docker/login-action@v1
37+
with:
38+
username: ${{ secrets.DOCKER_USERNAME }}
39+
password: ${{ secrets.DOCKER_AUTH_TOKEN }}
40+
41+
- name: Set up Ruby
42+
uses: ruby/setup-ruby@v1
43+
with:
44+
ruby-version: ${{ matrix.ruby }}
45+
bundler-cache: true
46+
47+
- run: make install
48+
49+
- name: Set up linter
50+
run: bundle add rubocop --version "~> 1.24.1" --group "development" --skip-install
51+
if: ${{ matrix.ruby != '2.4' }}
52+
53+
- run: bundle install --with development
54+
55+
- name: Run linter
56+
run: bundle exec rubocop
57+
if: ${{ matrix.ruby != '2.4' }}
58+
59+
- name: Run tests
60+
run: make test-docker
61+
62+
deploy:
63+
name: Deploy
64+
if: success() && github.ref_type == 'tag'
65+
needs: [ test ]
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Checkout sendgrid-ruby
69+
uses: actions/checkout@v2
70+
with:
71+
fetch-depth: 0
72+
73+
- name: Set up Ruby
74+
uses: ruby/setup-ruby@v1
75+
with:
76+
ruby-version: 3.1
77+
bundler-cache: true
78+
79+
- run: make install
80+
81+
- name: Create GitHub Release
82+
uses: sendgrid/dx-automator/actions/release@main
83+
with:
84+
footer: '**[RubyGems](https://rubygems.org/gems/sendgrid-ruby/versions/${version})**'
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: Publish to Rubygems
89+
env:
90+
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
91+
run: |
92+
mkdir -p $HOME/.gem
93+
touch $HOME/.gem/credentials
94+
chmod 0600 $HOME/.gem/credentials
95+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
96+
gem build *.gemspec
97+
gem push *.gem
98+
99+
notify-on-failure:
100+
name: Slack notify on failure
101+
if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
102+
needs: [ test, deploy ]
103+
runs-on: ubuntu-latest
104+
steps:
105+
- uses: rtCamp/action-slack-notify@v2
106+
env:
107+
SLACK_COLOR: failure
108+
SLACK_ICON_EMOJI: ':github:'
109+
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) }}
110+
SLACK_TITLE: Action Failure - ${{ github.repository }}
111+
SLACK_USERNAME: GitHub Actions
112+
SLACK_MSG_AUTHOR: twilio-dx
113+
SLACK_FOOTER: Posted automatically using GitHub Actions
114+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
115+
MSG_MINIMAL: true

.rubocop_todo.yml

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,57 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2020-09-18 20:20:54 UTC using RuboCop version 0.91.0.
3+
# on 2022-01-25 23:45:43 UTC using RuboCop version 1.22.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9+
# Offense count: 1
10+
# Cop supports --auto-correct.
11+
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
12+
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
13+
Bundler/OrderedGems:
14+
Exclude:
15+
- 'Gemfile'
16+
917
# Offense count: 1
1018
# Configuration parameters: Include.
1119
# Include: **/*.gemspec
1220
Gemspec/RequiredRubyVersion:
1321
Exclude:
1422
- 'sendgrid-ruby.gemspec'
1523

16-
# Offense count: 22
24+
# Offense count: 1
25+
# Cop supports --auto-correct.
26+
# Configuration parameters: EnforcedStyle.
27+
# SupportedStyles: final_newline, final_blank_line
28+
Layout/TrailingEmptyLines:
29+
Exclude:
30+
- 'Gemfile'
31+
32+
# Offense count: 24
1733
Lint/UselessAssignment:
1834
Exclude:
1935
- 'examples/scopes/scopes.rb'
2036
- 'spec/rack/sendgrid_webhook_verification_spec.rb'
2137

22-
# Offense count: 8
23-
# Configuration parameters: IgnoredMethods.
38+
# Offense count: 10
39+
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
2440
Metrics/AbcSize:
25-
Max: 144
26-
27-
# Offense count: 9
28-
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
29-
# ExcludedMethods: refine
30-
Metrics/BlockLength:
31-
Max: 96
41+
Max: 134
3242

3343
# Offense count: 3
3444
# Configuration parameters: CountComments, CountAsOne.
3545
Metrics/ClassLength:
36-
Max: 2006
37-
Exclude:
38-
- 'test/sendgrid/test_sendgrid-ruby.rb'
46+
Max: 2018
3947

40-
# Offense count: 41
41-
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
48+
# Offense count: 45
49+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
4250
Metrics/MethodLength:
4351
Max: 141
4452

45-
# Offense count: 2
46-
# Configuration parameters: CountKeywordArgs.
53+
# Offense count: 4
54+
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
4755
Metrics/ParameterLists:
4856
Max: 7
4957

@@ -76,15 +84,15 @@ Naming/PredicateName:
7684
- 'examples/helpers/eventwebhook/example.rb'
7785

7886
# Offense count: 35
87+
# Configuration parameters: AllowedConstants.
7988
Style/Documentation:
8089
Enabled: false
8190

82-
# Offense count: 4
83-
# Configuration parameters: EnforcedStyle.
91+
# Offense count: 3
92+
# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, IgnoredMethods.
8493
# SupportedStyles: annotated, template, unannotated
8594
Style/FormatStringToken:
86-
Exclude:
87-
- 'examples/emailactivity/emailactivity.rb'
95+
EnforcedStyle: unannotated
8896

8997
# Offense count: 97
9098
# Cop supports --auto-correct.
@@ -93,6 +101,14 @@ Style/FormatStringToken:
93101
Style/FrozenStringLiteralComment:
94102
Enabled: false
95103

104+
# Offense count: 1
105+
# Cop supports --auto-correct.
106+
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
107+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
108+
Style/HashSyntax:
109+
Exclude:
110+
- 'Gemfile'
111+
96112
# Offense count: 6
97113
Style/MixinUsage:
98114
Exclude:
@@ -103,9 +119,9 @@ Style/MixinUsage:
103119
- 'test/sendgrid/helpers/mail/test_attachment.rb'
104120
- 'test/sendgrid/helpers/mail/test_mail.rb'
105121

106-
# Offense count: 55
122+
# Offense count: 54
107123
# Cop supports --auto-correct.
108-
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
124+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
109125
# URISchemes: http, https
110126
Layout/LineLength:
111-
Max: 3211
127+
Max: 381

.travis.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
[2022-02-09] Version 6.6.1
5+
--------------------------
6+
**Library - Chore**
7+
- [PR #482](https://github.com/sendgrid/sendgrid-ruby/pull/482): upgrade supported language versions. Thanks to [@childish-sambino](https://github.com/childish-sambino)!
8+
- [PR #480](https://github.com/sendgrid/sendgrid-ruby/pull/480): add gh release to workflow. Thanks to [@shwetha-manvinkurke](https://github.com/shwetha-manvinkurke)!
9+
- [PR #478](https://github.com/sendgrid/sendgrid-ruby/pull/478): migrate to gh actions. Thanks to [@beebzz](https://github.com/beebzz)!
10+
11+
**Library - Fix**
12+
- [PR #479](https://github.com/sendgrid/sendgrid-ruby/pull/479): set version env var for tests. Thanks to [@beebzz](https://github.com/beebzz)!
13+
14+
415
[2021-11-03] Version 6.6.0
516
--------------------------
617
**Library - Feature**

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

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

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ install:
55

66
test:
77
bundle exec rake
8-
rubocop
98

109
test-integ: test
1110

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Twilio SendGrid Logo](twilio_sendgrid_logo.png)
22

3-
[![Travis Badge](https://travis-ci.com/sendgrid/sendgrid-ruby.svg?branch=main)](https://travis-ci.com/sendgrid/sendgrid-ruby)
3+
[![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)
44
[![Gem Version](https://badge.fury.io/rb/sendgrid-ruby.svg)](https://badge.fury.io/rb/sendgrid-ruby)
55
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
66
[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'sendgrid-ruby'
2+
3+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
4+
5+
##################################################
6+
# Add or Update a Contact #
7+
# POST /marketing/contacts #
8+
9+
data = JSON.parse('{
10+
"list_ids": [
11+
"ca7a3796-e8a8-4029-9ccb-df8937940562"
12+
],
13+
"contacts": [
14+
{
15+
"address_line_1": "123 Elm St.",
16+
"address_line_2": "Apt. 456",
17+
"city": "Denver",
18+
"country": "United States",
19+
"email": "example@example.com",
20+
"first_name": "User",
21+
"last_name": "Example"
22+
}
23+
]
24+
}')
25+
26+
response = sg.client.marketing.contacts.put(request_body: data)
27+
puts response.status_code
28+
puts response.body
29+
puts response.headers

0 commit comments

Comments
 (0)