Skip to content

Instantly share code, notes, and snippets.

@sessa
Created January 24, 2020 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sessa/5fc71e9bffc47b9473cc64e2c961f5d7 to your computer and use it in GitHub Desktop.
Save sessa/5fc71e9bffc47b9473cc64e2c961f5d7 to your computer and use it in GitHub Desktop.
{
"swagger": "2.0",
"info": {
"description": "Description",
"version": "1.0.0",
"title": "Bulk Mailer API",
"contact": {
"email": "admin@indigov.us"
}
},
"host": "api.indigov.us",
"basePath": "/v1/bulk-mailer-jobs",
"schemes": ["https", "http"],
"paths": {
"/search": {
"get": {
"tags": ["search"],
"description": "",
"parameters": [
{
"in": "query",
"required": true,
"name": "totalAudienceSize",
"type": "integer",
"default": 0
},
{
"in": "query",
"name": "dataSource",
"type": "array",
"items": {
"type": "string",
"enum": ["database", "l2"]
}
},
{
"in": "query",
"name": "zipcodes",
"type": "array",
"items": {
"type": "string"
}
},
{
"in": "query",
"name": "tags",
"type": "array",
"items": {
"type": "string"
}
},
{
"in": "query",
"name": "topics",
"type": "array",
"items": {
"type": "string"
}
},
{
"in": "query",
"name": "counties",
"type": "array",
"items": {
"type": "string"
}
},
{
"in": "query",
"name": "validatedUsers",
"type": "boolean",
"default": true
},
{
"in": "query",
"name": "findAllConstituents",
"type": "boolean",
"default": false
},
{
"in": "query",
"name": "includeNewsletterSubscribers",
"type": "boolean",
"default": false
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/campaigns": {
"get": {
"tags": ["campaigns"],
"summary": "Get a list of campaigns",
"description": "This request will provide a potentially paginated list of campaigns",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Campaign"
}
}
}
}
},
"post": {
"tags": ["campaigns"],
"summary": "Add a new campaign",
"description": "This request will trigger the backend to create a Bulk Mailer Job",
"operationId": "addCampaign",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{
"in": "body",
"name": "campaign",
"description": "Creates a new bulk mailer job for",
"required": true,
"schema": {
"$ref": "#/definitions/Campaign"
}
}
],
"responses": {
"405": {
"description": "Invalid input"
}
},
"security": [
{
"bulk_mailer_auth": ["write:campaigns", "read:campaigns"]
}
]
}
},
"/campaigns/{campaignId}": {
"get": {
"tags": ["campaigns"],
"summary": "Find campaign by ID",
"description": "Returns a single campaign",
"operationId": "getCampaignById",
"produces": ["application/json"],
"parameters": [
{
"name": "campaignId",
"in": "path",
"description": "ID of campaign to return",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Campaign"
}
},
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Campaign not found"
}
},
"security": [
{
"api_key": []
}
]
},
"put": {
"tags": ["campaigns"],
"summary": "Update a campaign",
"description": "",
"operationId": "updateCampaign",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{
"in": "body",
"name": "body",
"description": "Update a campaign",
"required": true,
"schema": {
"$ref": "#/definitions/Campaign"
}
}
],
"responses": {
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Campaign not found"
},
"405": {
"description": "Validation exception"
}
},
"security": [
{
"bulk_mailer_auth": ["write:campaigns", "read:campaigns"]
}
]
},
"delete": {
"tags": ["campaigns"],
"summary": "Deletes a campaign",
"description": "",
"operationId": "deleteCampaign",
"produces": ["application/json"],
"parameters": [
{
"name": "campaignId",
"in": "path",
"description": "Delete Campaign",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Campaign not found"
}
},
"security": [
{
"bulk_mailer_auth": ["write:campaigns", "read:campaigns"]
}
]
}
},
"/campaign/{campaignId}/addUsers - [TODO]": {
"post": {
"tags": ["campaigns"],
"summary": "TODO - Manually add users to a campaign",
"description": "Manually add users to campaign",
"parameters": [
{
"in": "query",
"name": "query",
"required": true,
"type": "object",
"schema": {
"type": "string",
"$ref": "#/definitions/Campaign"
}
}
],
"put": {
"description": "Update manually added users to campaign",
"parameters": [],
"responses": {
"200": {
"description": "OK"
}
}
},
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/campaign/{campaignId}/removeUsers - [TODO]": {
"post": {
"tags": ["campaigns"],
"summary": "TODO - Manually remove users to a campaign",
"description": "Manually remove users to campaign",
"parameters": [
{
"in": "query",
"name": "query",
"required": true,
"type": "object",
"schema": {
"type": "string",
"$ref": "#/definitions/Campaign"
}
}
],
"put": {
"description": "Update manually added users to campaign",
"parameters": [],
"responses": {
"200": {
"description": "OK"
}
}
},
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/campaign/{campaignId}/kill": {
"post": {
"tags": ["campaigns"],
"summary": "Kills a campaign",
"description": "This will stop the current job from processing and potentially complete all 'working' jobs (need to discuss).",
"operationId": "killCampaign",
"produces": ["application/json"],
"parameters": [
{
"name": "campaignId",
"in": "path",
"description": "Kill Campaign",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Campaign not found"
}
},
"security": [
{
"bulk_mailer_auth": ["write:campaigns", "read:campaigns"]
}
]
}
}
},
"securityDefinitions": {
"bulk_mailer_auth": {
"type": "oauth2",
"authorizationUrl": "tbd",
"flow": "implicit",
"scopes": {
"write:campaigns": "modify campaigns in your account",
"read:campaigns": "read your campaigns"
}
},
"api_key": {
"type": "apiKey",
"name": "api_key",
"in": "header"
}
},
"definitions": {
"Campaign": {
"type": "object",
"required": [
"campaign_id",
"message",
"delivery_method",
"staffer",
"subject",
"mailer_type",
"total_audience_size",
"data_source"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"campaign_id": {
"type": "integer",
"format": "int32",
"example": 1002
},
"message": {
"type": "string",
"description": "Message sent to constituents",
"example": "<p>This is my message</p>"
},
"staffer": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"zendesk_user_id": {
"type": "integer"
}
},
"example": {
"name": "Alex Kouts",
"zendesk_user_id": 3322441122
},
"description": "The name of the user that created the campaign"
},
"subject": {
"type": "string",
"example": "PACT Act",
"description": "The subject of the campaign"
},
"delivery_method": {
"type": "string",
"enum": ["phyiscal", "digital"],
"description": "How the campaign was delivered (physical or digital)"
},
"mailer_type": {
"type": "string",
"enum": ["499", "bulk mailer"],
"description": "499 or Bulk Mailer"
},
"total_audience_size": {
"type": "integer",
"description": "Total number of constituents who will receive a mailer",
"example": "200000"
},
"data_source": {
"type": "string",
"enum": ["database", "l2"],
"description": "Data source that was searched"
},
"universe": {
"type": "string",
"description": "L2 Universe selected"
},
"zipcodes": {
"description": "List of Zipcodes used to filter constituents",
"type": "array",
"items": {
"type": "string"
},
"example": ["78757", "55001"]
},
"counties": {
"type": "array",
"items": {
"type": "string",
"description": "List of Counties used to filter constituents"
},
"example": ["Calhoun", "Mercer"]
},
"topics": {
"type": "array",
"items": {
"type": "string",
"description": "List of Topics used to filter constituents"
},
"example": ["animal_welfare", "gun_control"]
},
"tags": {
"type": "array",
"items": {
"type": "string",
"description": "List of Tags used to filter constituents"
},
"example": ["animal_welfare_pro", "gun_control_con"]
},
"job_status": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"total": {
"type": "integer"
},
"progress": {
"type": "integer"
},
"status": {
"type": "string",
"enum": ["queued", "working", "failed", "completed", "killed"]
},
"message": {
"type": "string"
}
}
}
},
"json": {
"name": "Campaigns"
}
},
"ApiResponse": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"type": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
},
"externalDocs": {
"description": "Find out more about Swagger",
"url": "http://swagger.io"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment