sendx-ruby-sdk

SendX - the Ruby gem for the SendX REST API

Introduction

SendX is an email marketing product. It helps you convert website visitors to customers, send them promotional emails, engage with them using drip sequences and craft custom journeys using powerful but simple automations.

The SendX API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. The SendX Rest API doesn’t support bulk updates. You can work on only one object per request.

Installation

Build a gem

To build the Ruby code into a gem:

gem build sendx-ruby-sdk.gemspec

Then either install the gem locally:

gem install ./sendx-ruby-sdk-1.0.0.gem

(for development, run gem install --dev ./sendx-ruby-sdk-1.0.0.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'sendx-ruby-sdk', '~> 1.0.0'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/sendx/sendx-ruby-sdk, then add the following in the Gemfile:

gem 'sendx-ruby-sdk', :git => 'https://github.com/sendx/sendx-ruby-sdk.git'

Include the Ruby code directly

Include the Ruby code directly using -I as follows:

ruby -Ilib script.rb

Getting Started

Please follow the installation procedure and then run the following code:

# Load the gem
require 'time'
require 'sendx-ruby-sdk'
# setup authorization
SendX.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = 'YOUR API KEY'
  config.server_index = 2
end

api_instance = SendX::ContactApi.new
contact_request = SendX::ContactRequest.new(
  email: "[email protected]",
  first_name: "John",
  last_name: "Doe",
  company: "SendX",
  last_tracked_ip: "34.94.159.140",
  tags: ["MKdhTovsTJDetCyrJmRySL"],
  custom_fields: {
        'fnwfnke23kn4kn' => "VIP",
        "9i0jinjn0ib0"=> "Subscribers"
    },
)

begin
  # Create a contact
  result = api_instance.create_contact(contact_request)
  p result
rescue SendX::ApiError => e
  puts "Error when calling ContactApi->create_contact: #{e}"
end

Documentation for API Endpoints

All URIs are relative to https://api.sendx.io/api/v1/rest

Class Method HTTP request Description
SendX::CampaignApi create_campaign POST /campaign Create Campaign
SendX::CampaignApi delete_campaign DELETE /campaign/campaignId Delete Campaign
SendX::CampaignApi edit_campaign PUT /campaign/campaignId Edit Campaign
SendX::CampaignApi get_all_campaigns GET /campaign Get All Campaigns
SendX::CampaignApi get_campaign_by_id GET /campaign/campaignId Get Campaign By Id
SendX::ContactApi create_contact POST /contact Create a contact
SendX::ContactApi delete_contact DELETE /contact/contactId Delete Contact
SendX::ContactApi get_all_contacts GET /contact Get All Contacts
SendX::ContactApi get_contact_by_id GET /contact/contactId Get Contact by ID
SendX::ContactApi unsubscribe_contact POST /contact/unsubscribe/contactId Unsubscribe Contact
SendX::ContactApi update_contact PUT /contact/contactId Update Contact
SendX::ListApi create_list POST /list Create List
SendX::ListApi delete_list DELETE /list/listId Delete List
SendX::ListApi get_all_lists GET /list Get All Lists
SendX::ListApi get_list_by_id GET /list/listId Get List
SendX::ListApi update_list PUT /list/listId Update List
SendX::ReportsApi get_campaign_report GET /report/campaign/campaignId Get CampaignReport Data
SendX::SenderApi create_sender POST /sender Create Sender
SendX::SenderApi get_all_senders GET /sender Get All Senders
SendX::TagsApi create_tag POST /tag Create a Tag
SendX::TagsApi delete_tag DELETE /tag/tagId Delete a Tag
SendX::TagsApi get_all_tags GET /tag Get All Tags
SendX::TagsApi get_tag_by_id GET /tag/tagId Get a Tag by ID
SendX::TagsApi update_tag PUT /tag/tagId Update a Tag

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

apiKeyAuth

  • Type: API key
  • API key parameter name: X-Team-ApiKey
  • Location: HTTP header