-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
406 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { http } from "@openfn/language-common"; | ||
import { http } from '@openfn/language-common'; | ||
|
||
const getCatBreeds = (callback) => async (state) => { | ||
try { | ||
const responses = await http.get(`${state.configuration.baseUrl}/breeds`); | ||
const data = responses.data; | ||
const newState = { ...state, data: data, references: [] }; | ||
const response = await http.get(`${state.configuration.baseUrl}/breeds`); | ||
const data = response.data; | ||
const newState = { ...state, data: data }; | ||
return callback(newState); | ||
} catch (error) { | ||
console.error(error); | ||
return state; | ||
} | ||
}; | ||
|
||
export default getCatBreeds; | ||
export default getCatBreeds; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Adds a tag to a member of a list. | ||
* Sends a POST request to the /lists/{list_id}/members/{subscriber_hash}/tags endpoint of the Mailchimp API. | ||
* @parameter callback {{Function}} - a callback which is invoked with the resulting state at the end of this operation. Allows users to customise the resulting state. State.data includes the response from the Mailchimp API. | ||
* @returns A function that updates the state with the response from the Mailchimp API. | ||
*/ | ||
declare function addTagToMember(callback: (fn: (inState: State) => State)): (outState: State) => State; | ||
type AddTagToMemberParams = {{ list_id: string; subscriber_hash: string; }}; | ||
type AddTagToMemberResponse = any; // Update with the actual response type from the Mailchimp API | ||
type C = {{ baseUrl: string; }}; | ||
type State<C = {{}}, D = {{}}> = {{ configuration: C; data: AddTagToMemberResponse; }}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { http } from '@openfn/language-common'; | ||
|
||
const addTagToMember = (callback) => async (outState) => { | ||
const { list_id, subscriber_hash } = outState.configuration; | ||
|
||
try { | ||
const response = await http.post(`/lists/${list_id}/members/${subscriber_hash}/tags`); | ||
const newState = { ...outState, data: response.data }; | ||
return callback(newState); | ||
} catch (error) { | ||
console.error(error); | ||
return outState; | ||
} | ||
}; | ||
|
||
export default addTagToMember; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Create an OpenFn function that accesses the /tagMembers endpoint | ||
Create an OpenFn function that adds a tag to a member via the /lists/{list_id}/members/{subscriber_hash}/tags endpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,249 @@ | ||
// Mailchimp api spec goes here | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"title": "Mailchimp API", | ||
"version": "1.0.0" | ||
}, | ||
"paths": { | ||
"/lists/{list_id}/members/{subscriber_hash}/goals": { | ||
"get": { | ||
"summary": "Get Member Goals", | ||
"description": "Get information about recent goal events for a specific list member.", | ||
"operationId": "getListMemberGoals", | ||
"parameters": [ | ||
{ | ||
"name": "list_id", | ||
"in": "path", | ||
"required": true, | ||
"description": "The ID of the list.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "subscriber_hash", | ||
"in": "path", | ||
"required": true, | ||
"description": "The hash of the subscriber.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "Successful response", | ||
"content": { | ||
"application/json": { | ||
"example": {} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"post": { | ||
"summary": "Create Member Goal", | ||
"description": "Create a new goal event for a specific list member.", | ||
"operationId": "createListMemberGoal", | ||
"parameters": [ | ||
{ | ||
"name": "list_id", | ||
"in": "path", | ||
"required": true, | ||
"description": "The ID of the list.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "subscriber_hash", | ||
"in": "path", | ||
"required": true, | ||
"description": "The hash of the subscriber.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"requestBody": { | ||
"required": true, | ||
"content": { | ||
"application/json": { | ||
"example": {} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"201": { | ||
"description": "Successful response", | ||
"content": { | ||
"application/json": { | ||
"example": {} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/lists/{list_id}/members/{subscriber_hash}/tags": { | ||
"get": { | ||
"summary": "Get Member Tags", | ||
"description": "Get all the tags assigned to a contact.", | ||
"operationId": "getListMemberTags", | ||
"parameters": [ | ||
{ | ||
"name": "list_id", | ||
"in": "path", | ||
"required": true, | ||
"description": "The ID of the list.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "subscriber_hash", | ||
"in": "path", | ||
"required": true, | ||
"description": "The hash of the subscriber.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "Successful response", | ||
"content": { | ||
"application/json": { | ||
"example": {} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"post": { | ||
"summary": "Manage Member Tags", | ||
"description": "Manage the tags assigned to a contact.", | ||
"operationId": "manageListMemberTags", | ||
"parameters": [ | ||
{ | ||
"name": "list_id", | ||
"in": "path", | ||
"required": true, | ||
"description": "The ID of the list.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "subscriber_hash", | ||
"in": "path", | ||
"required": true, | ||
"description": "The hash of the subscriber.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"requestBody": { | ||
"required": true, | ||
"content": { | ||
"application/json": { | ||
"example": {} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"200": { | ||
"description": "Successful response", | ||
"content": { | ||
"application/json": { | ||
"example": {} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/lists/{list_id}/members/{subscriber_hash}/events": { | ||
"get": { | ||
"summary": "Get Member Events", | ||
"description": "Get website or in-app actions for a specific list member.", | ||
"operationId": "getListMemberEvents", | ||
"parameters": [ | ||
{ | ||
"name": "list_id", | ||
"in": "path", | ||
"required": true, | ||
"description": "The ID of the list.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "subscriber_hash", | ||
"in": "path", | ||
"required": true, | ||
"description": "The hash of the subscriber.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "Successful response", | ||
"content": { | ||
"application/json": { | ||
"example": {} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"post": { | ||
"summary": "Trigger Member Events", | ||
"description": "Trigger targeted automations based on website or in-app actions.", | ||
"operationId": "triggerListMemberEvents", | ||
"parameters": [ | ||
{ | ||
"name": "list_id", | ||
"in": "path", | ||
"required": true, | ||
"description": "The ID of the list.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "subscriber_hash", | ||
"in": "path", | ||
"required": true, | ||
"description": "The hash of the subscriber.", | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"requestBody": { | ||
"required": true, | ||
"content": { | ||
"application/json": { | ||
"example": {} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"200": { | ||
"description": "Successful response", | ||
"content": { | ||
"application/json": { | ||
"example": {} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.