Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.

Adds send grid job. Fixes #49 - #86

Merged
rickr merged 2 commits into
masterfrom
issue#49
Jul 14, 2017
Merged

rickr merged 2 commits into
masterfrom
issue#49

Conversation

@rickr

@rickr rickr commented Jul 14, 2017

Copy link
Copy Markdown
Contributor

Description of changes

Adds a new job to run when a user signs up to add them to our sendgrid contact list.

Issue Resolved

Fixes #49

@ghost ghost assigned rickr Jul 14, 2017
@ghost ghost added the in progress label Jul 14, 2017
@rickr
rickr requested a review from hpjaj July 14, 2017 01:57

@hpjaj hpjaj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @rickr on a tough feature! Just a few comments.

Comment thread app/lib/send_grid_client.rb Outdated
class SendGridClientError < StandardError; end

def initialize
@sendgrid = SendGrid::API.new(api_key: OperationCode.fetch_secret_with(name: :sendgrid_api_key))

@hpjaj hpjaj Jul 14, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is a bit long. Perhaps abstract this into a private method?

def instantiate_sendgrid
  key = OperationCode.fetch_secret_with name: :sendgrid_api_key

  SendGrid::API.new api_key: key  
end

or

def oc_sendgrid_key
  OperationCode.fetch_secret_with name: :sendgrid_api_key
end

def sendgrid_object
  SendGrid::API.new api_key: oc_sendgrid_key  
end

Comment thread app/lib/send_grid_client.rb Outdated
private

def add_recipient(data)
response = Response.new(@sendgrid.client.contactdb.recipients.post(request_body: [data]))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is pretty complex. Perhaps abstract this into its own private method?

def generate_sendgrid_response(data)
  Response.new(@sendgrid.client.contactdb.recipients.post(request_body: [data]))
end

Also, perhaps add some commented out documentation explaining/referencing the chain from @sendgrid to .post?

Comment thread app/lib/send_grid_client.rb Outdated
end

def add_recipient_to_list(recipient_id)
response = Response.new(@sendgrid.client.contactdb.lists._(LIST_ID).recipients._(recipient_id).post())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@rickr

rickr commented Jul 14, 2017

Copy link
Copy Markdown
Contributor Author

@hpjaj Fixes are in.

@rickr
rickr merged commit e49d7bb into master Jul 14, 2017
@ghost ghost removed the in progress label Jul 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create an 'add_to_sendgrid' job

2 participants