Giter Club home page Giter Club logo

swagger_client's Introduction

swagger_client

SwaggerClient - the Ruby gem for the Newsletter2Go-API (https://api.newsletter2go.com)

JSON first

Our REST API exchanges data in the JSON data format. Every parameter you pass (with a few exceptions e.g. when you upload files) should therefore be formatted in JSON and our API will always return results in JSON as well.

Very RESTful

Our API follows a very RESTful approach.
Most importantly, we implemented the following four request methods for CRUD operations:

POST - Create a new record
GET - Retrieve / read records without changing anything
PATCH - Update an existing record
DELETE - Delete one or more records

HTTP Status codes

We also follow the most common HTTP status codes when outputting the API response:

2xx - Successful calls
200 - Success
201 - Created

4xx - Error codes
400 - API error - inspect the body for detailed information about what went wrong. The most common error is \"code\":1062, which means, that a unique constraint was hit. For example if the name of the group is already in use.
401 - Not authenticated - invalid access_token. Check if the access_token has expired or is incorrect.
403 - Access denied
404 - Call not available or no records found

5xx - API error - please contact support

Response format

The API always returns data in the following format

{
  \"info\": {
    \"count\": 0
  },
  \"value\": [
   {
    \"key\": \"value\"
   }
  ]
}


Recurring GET parameters

  • _filter - a complex filter for filtering the result set based on FIQL.
  • _limit - the maximum number records returned.
  • _offset - pagination for the result-set
  • _expand - submit true to get all default fields of the resource
  • _fields - submit a comma-separated list of case-sensetive field-names to get the values of these fields in the response. You can use this the get values of custom attribute of recipients for example.


Filter language

The filter language for filtering results is based on FIQL.
With the only restriction, that plain values must be surrounded by \". For example first_name==\"Max\"
The following operators are supported
  • Equals - ==
  • Not equals - =ne=
  • Greater than - =gt=
  • Greater than equals - =ge=
  • Lower than - =lt=
  • Lower than equals - =le=
  • Like - =like= (in combination with % you are able to search for starts with, ends with, contains. For example first_name=like=\"%Max%\")
  • Not like - =nlike=
  • Logical and - ;
  • Logical or - ,


How to make Calls?

After you authenticated and received a valid access_token, you have to pass it in every consecutive call. Use the Authorization header for that purpose as follows:
xhr.setRequestHeader(\"Authorization\", \"Bearer \" + your_access_token);

Every call takes additional parameters that can be used to modify the request. These parameters should be passed as JSON
var params = {
  \"key\"= \"value\"
}
xhr.send(JSON.stringify(params));


Sending transactional emails

It is very important to understand the following concept in order for you to take full advantage of our powerful personalization features and our detailed reports when sending transactional emails.

First, you will have to create a new mailing. We recommend that you create that mailing through our UI in order to take full advantage of our powerful newsletter builder. This way, we will automatically create cross-client optimized and responsive HTML. Yet another advantage lies in the possibility for other users (e.g. the marketing team) to change the layout or the content of the mailing without having to contact the developer (you).

Of course, it is also possible to create a mailing through the API. When doing so, you can also take advantage of our cross-client optimized responsive HTML by passing us JSON or YAML according to the Newsletter2Go Markup Language.
No matter how you create the mailing, try to create *one* reusable template. You can customize individual emails by inserting placeholders for personalized fields such as name, products or other information that will be filled through an API call when sending.

By only creating one template, you can take advantage of our full reporting since all emails will be treated part of a \"campaign\". When you change that template, we will create a new version of the mailing in the background and you will be able to see the difference in performance in the reports. This is particularily useful when you are trying to test and optimize different versions of transactional emails such as a sign up email.

After creating a mailing, you will have access to its ID. Use that ID to actually send the email in the next step.

When sending an email, you have to pass the newsletter ID and information about the recipient. Either pass the recipient ID or pass all the recipient's data (including the e-mail-address) as JSON.

If you only pass the recipient ID, we will use his or her data from your list to personalize the mailing. If you pass full recipient data as JSON, we will try to merge the data with existing data from your list.

You can also pass additional data such as product data which is not saved in your list. Just make sure that the placeholders in the source of the mailing correspond to the parameters that you are passing.
This way you can also create for-loops which can be useful if you pass different amounts of data for each recipient (e.g. a purchase confirmation where you want to list all the products that were just bought).

This SDK is automatically generated by the Swagger Codegen project:

  • API version: 1.0.0
  • Package version: 1.0.0
  • Build date: 2016-06-08T07:00:17.910Z
  • Build package: class io.swagger.codegen.languages.RubyClientCodegen

Installation

Build a gem

To build the Ruby code into a gem:

gem build swagger_client.gemspec

Then either install the gem locally:

gem install ./swagger_client-1.0.0.gem

(for development, run gem install --dev ./swagger_client-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 'swagger_client', '~> 1.0.0'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/YOUR_GIT_USERNAME/YOUR_GIT_REPO, then add the following in the Gemfile:

gem 'swagger_client', :git => 'https://github.com/YOUR_GIT_USERNAME/YOUR_GIT_REPO.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 'swagger_client'

# Setup authorization
SwaggerClient.configure do |config|
  # Configure OAuth2 access token for authorization: OAuth
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SwaggerClient::AttributeApi.new

attribute = SwaggerClient::AttributePost.new # AttributePost | the data to save


begin
  #creates a new attribute
  result = api_instance.create_attribute(attribute)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling AttributeApi->create_attribute: #{e}"
end

Documentation for API Endpoints

All URIs are relative to https://api.newsletter2go.com

Class Method HTTP request Description
SwaggerClient::AttributeApi create_attribute POST /attributes creates a new attribute
SwaggerClient::AttributeApi delete_attribute DELETE /lists/{lid}/attributes/{id} delete the attribute
SwaggerClient::AttributeApi get_attributes GET /lists/{lid}/attributes get all Attributes of selected list
SwaggerClient::AttributeApi update_attribute PATCH /attributes/{id} update the attribute
SwaggerClient::AuthorizationApi get_token POST /oauth/v2/token Endpoint for retrieving a token
SwaggerClient::CompanyApi get_company GET /companies get the details of a company
SwaggerClient::CompanyApi update_company PATCH /companies/{id} update the Company
SwaggerClient::GroupApi add_recipient_to_group POST /lists/{lid}/groups/{gid}/recipients/{id} add single recipient to group
SwaggerClient::GroupApi add_recipients_to_group POST /lists/{lid}/groups/{gid}/recipients add all Recipients to the given group
SwaggerClient::GroupApi create_group POST /groups creates a new group
SwaggerClient::GroupApi delete_group DELETE /groups/{id} delete the Group
SwaggerClient::GroupApi get_groups GET /lists/{lid}/groups get all Group of selected list
SwaggerClient::GroupApi get_recipients_by_group GET /lists/{lid}/groups/{gid}/recipients get all Recipients of selected group
SwaggerClient::GroupApi remove_recipient_from_group DELETE /lists/{lid}/groups/{gid}/recipients/{id} remove single recipient from group
SwaggerClient::GroupApi remove_recipients_from_group DELETE /lists/{lid}/groups/{gid}/recipients remove all Recipients from given group
SwaggerClient::GroupApi update_group PATCH /groups/{id} update the Group
SwaggerClient::ListApi create_list POST /lists creates a new list
SwaggerClient::ListApi delete_list DELETE /lists/{id} delete the List
SwaggerClient::ListApi get_lists GET /lists get all lists
SwaggerClient::ListApi get_recipients GET /lists/{lid}/recipients get all Recipients of selected list
SwaggerClient::ListApi remove_recipients_from_list DELETE /lists/{lid}/recipients remove all Recipients from selected list
SwaggerClient::ListApi update_list PATCH /lists/{id} update the List
SwaggerClient::ListApi update_recipients PATCH /lists/{lid}/recipients update all Recipients in selected list
SwaggerClient::NewsletterApi create_newsletter POST /lists/{lid}/newsletters creates a new newsletter
SwaggerClient::NewsletterApi get_newsletter GET /newsletters/{id} get one newsletter
SwaggerClient::NewsletterApi get_newsletters GET /lists/{lid}/newsletters get all newsletters of the given list
SwaggerClient::NewsletterApi get_reports GET /lists/{lid}/newsletters/{nid}/aggregations get reports for the newsletter aggregated by days
SwaggerClient::NewsletterApi send_newsletter POST /newsletters/{id}/send Sends the newsletter to a list or group
SwaggerClient::NewsletterApi update_newsletter PATCH /newsletters/{id} update the Newsletter
SwaggerClient::RecipientApi add_recipient_to_group POST /lists/{lid}/groups/{gid}/recipients/{id} add single recipient to group
SwaggerClient::RecipientApi add_recipients_to_group POST /lists/{lid}/groups/{gid}/recipients add all Recipients to the given group
SwaggerClient::RecipientApi create_recipient POST /recipients create new recipient(s) or updates existing ones
SwaggerClient::RecipientApi delete_recipient DELETE /lists/{lid}/recipients/{id} delete the recipient
SwaggerClient::RecipientApi get_recipients GET /lists/{lid}/recipients get all Recipients of selected list
SwaggerClient::RecipientApi get_recipients_by_group GET /lists/{lid}/groups/{gid}/recipients get all Recipients of selected group
SwaggerClient::RecipientApi import_recipients_init POST /lists/{lid}/recipients/import/init Initialize the import of recipients by file
SwaggerClient::RecipientApi import_recipients_save POST /lists/{lid}/recipients/import/save Start the import recipients by file
SwaggerClient::RecipientApi import_recipients_statistics GET /import/{id}/info Get statistics about the import by file
SwaggerClient::RecipientApi remove_recipient_from_group DELETE /lists/{lid}/groups/{gid}/recipients/{id} remove single recipient from group
SwaggerClient::RecipientApi remove_recipients_from_group DELETE /lists/{lid}/groups/{gid}/recipients remove all Recipients from given group
SwaggerClient::RecipientApi remove_recipients_from_list DELETE /lists/{lid}/recipients remove all Recipients from selected list
SwaggerClient::RecipientApi subscribe_recipient POST /forms/submit/{code} Creates a new recipient and sends a DOI-Mail
SwaggerClient::RecipientApi update_recipient PATCH /lists/{lid}/recipients/{id} update the recipient.
SwaggerClient::RecipientApi update_recipients PATCH /lists/{lid}/recipients update all Recipients in selected list
SwaggerClient::ReportApi get_reports GET /lists/{lid}/newsletters/{nid}/aggregations get reports for the newsletter aggregated by days
SwaggerClient::UserApi get_users GET /users get all users of the company where the current user has access to
SwaggerClient::UserApi update_user PATCH /users/{id} update the user

Documentation for Models

Documentation for Authorization

OAuth

  • Type: OAuth
  • Flow: implicit
  • Authorization URL: /oauth/v2/token
  • Scopes: N/A

Basic

  • Type: HTTP basic authentication

swagger_client's People

Contributors

angmeng avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.