Skip to content
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,25 @@ simple_spark.recipient_lists.delete(your_list_id)

<a href="https://developers.sparkpost.com/api/recipient-lists/#recipient-lists-delete-delete-a-recipient-list" target="_blank">see SparkPost API Documentation</a>


### Recipient Validation

#### Validate

Validates a single recipient by email address.

```ruby
simple_spark.recipient_validation.validate('[email protected]')
```

<a href="https://developers.sparkpost.com/api/recipient-validation/#recipient-validation-get-email-address-validation" target="_blank">see SparkPost API Documentation</a>

## Changelog

### 1.0.13

- Add Recipient Validation Endpoint

### 1.0.12 Fix param name on suppression list https://github.com/leadmachineapp/simple_spark/pull/27

### 1.0.10 / 1.0.11 Minor documentation updates
Expand Down
1 change: 1 addition & 0 deletions lib/simple_spark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
require 'simple_spark/endpoints/events'
require 'simple_spark/endpoints/webhooks'
require 'simple_spark/endpoints/recipient_lists'
require 'simple_spark/endpoints/recipient_validation'
require 'simple_spark/endpoints/relay_webhooks'
require 'simple_spark/endpoints/subaccounts'
require 'simple_spark/endpoints/suppression_list'
Expand Down
4 changes: 4 additions & 0 deletions lib/simple_spark/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,9 @@ def suppression_list
def recipient_lists
Endpoints::RecipientLists.new(self)
end

def recipient_validation
Endpoints::RecipientValidation.new(self)
end
end
end
31 changes: 31 additions & 0 deletions lib/simple_spark/endpoints/recipient_validation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module SimpleSpark
module Endpoints
# Provides access to the /recipient-validation endpoint
# @note Example validation
# {
# "valid": false,
# "result": "undeliverable",
# "reason": "Invalid Domain",
# "is_role": false,
# "is_disposable": false,
# "is_free": false
# }
# @note See: https://developers.sparkpost.com/api/recipient-validation/
class RecipientValidation
attr_accessor :client

def initialize(client)
@client = client
end

# Validate a recipient email address.
# @param address [String] the email address to validate
# @return [Hash] a Recipient Validation hash object
# @note See: https://developers.sparkpost.com/api/recipient-validation/#recipient-validation-get-email-address-validation
def validate(address)
address = @client.url_encode(address)
@client.call(method: :get, path: "recipient-validation/single/#{address}")
end
end
end
end
2 changes: 1 addition & 1 deletion lib/simple_spark/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module SimpleSpark
VERSION = "1.0.12"
VERSION = "1.0.13"
end
4 changes: 4 additions & 0 deletions spec/simple_spark/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
specify { expect(client.recipient_lists.class).to eq(SimpleSpark::Endpoints::RecipientLists) }
end

context 'recipient_validation' do
specify { expect(client.recipient_validation.class).to eq(SimpleSpark::Endpoints::RecipientValidation) }
end

end
end
end