-
Notifications
You must be signed in to change notification settings - Fork 1
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
8 changed files
with
164 additions
and
29 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 |
---|---|---|
|
@@ -43,6 +43,8 @@ You can find your Courier API key in your [Courier Settings](https://app.courier | |
- `courier whoami` – Display the currently authenticated workspace | ||
- `courier send` - Send a notification to a user, list, or audience | ||
- `courier track` - Send a track event to trigger a Courier Automations | ||
- `courier users:get` - Fetch the data for a given user ID | ||
- `courier users:set` - Overwrite a user's profile with the provided data | ||
- `courier digests:flush` – Flush any currently queued events for a given user + digest | ||
- `courier translations:upload` - Upload .PO files to your Courier workspace | ||
- `courier translations:download` - Download .PO files from your Courier workspace | ||
|
@@ -60,6 +62,9 @@ $ courier send --user user123 --elemental my-template.json --foo bar | |
$ courier track my-event user123 --foo bar | ||
$ courier users:get user123 | ||
$ courier users:set user123 --email [email protected] --tel 555-867-5309 | ||
$ courier digests:flush user123 my-digest-id | ||
$ courier translations:upload en-US ./translations/en-US.po | ||
|
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
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,36 @@ | ||
import React, {useEffect, useState} from 'react'; | ||
import UhOh from '../components/UhOh.js'; | ||
import Request from '../components/Request.js'; | ||
import Response from '../components/Response.js'; | ||
import api from '../lib/api.js'; | ||
|
||
interface IResponse { | ||
res: Response; | ||
json?: any; | ||
err?: Error; | ||
} | ||
|
||
export default ({params}: {params: any}) => { | ||
const [resp, setResp] = useState<IResponse | undefined>(); | ||
|
||
const userId = params?._?.[0]; | ||
if (!userId) { | ||
return <UhOh text="You must specify a user ID." />; | ||
} | ||
|
||
const request = { | ||
method: 'GET', | ||
url: `/profiles/${userId}`, | ||
}; | ||
|
||
useEffect(() => { | ||
api(request).then(res => setResp(res)); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<Request request={request} response={resp} /> | ||
<Response response={resp} /> | ||
</> | ||
); | ||
}; |
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,48 @@ | ||
import React, {useEffect, useState} from 'react'; | ||
import UhOh from '../components/UhOh.js'; | ||
import Request from '../components/Request.js'; | ||
import Response from '../components/Response.js'; | ||
import api from '../lib/api.js'; | ||
|
||
interface IResponse { | ||
res: Response; | ||
json?: any; | ||
err?: Error; | ||
} | ||
|
||
export default ({params}: {params: any}) => { | ||
const [resp, setResp] = useState<IResponse | undefined>(); | ||
|
||
const userId = params?._?.[0]; | ||
if (!userId) { | ||
return <UhOh text="You must specify a user ID." />; | ||
} | ||
|
||
const {_, ...properties} = params; | ||
|
||
if (properties.tel) { | ||
properties.phone_number = properties.tel; | ||
delete properties.tel; | ||
} | ||
|
||
const request = { | ||
method: 'PUT', | ||
url: `/profiles/${userId}`, | ||
body: { | ||
profile: { | ||
...properties, | ||
}, | ||
}, | ||
}; | ||
|
||
useEffect(() => { | ||
api(request).then(res => setResp(res)); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<Request request={request} response={resp} /> | ||
<Response response={resp} /> | ||
</> | ||
); | ||
}; |
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
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 |
---|---|---|
|
@@ -3,6 +3,8 @@ import Help from './commands/Help.js'; | |
import Config from './commands/Config.js'; | ||
import WhoAmI from './commands/WhoAmI.js'; | ||
import Track from './commands/Track.js'; | ||
import UsersGet from './commands/UsersGet.js'; | ||
import UsersSet from './commands/UsersSet.js'; | ||
import Send from './commands/Send.js'; | ||
import DigestFlush from './commands/DigestFlush.js'; | ||
import TranslationsDownload from './commands/TranslationsDownload.js'; | ||
|
@@ -27,10 +29,11 @@ mappings.set('help', { | |
component: () => { | ||
return <Help mappings={mappings} />; | ||
}, | ||
noApiKeyRequired: true | ||
noApiKeyRequired: true, | ||
}); | ||
mappings.set('config', { | ||
instructions: 'Persist your Courier API key into a .courier file in your current working directory', | ||
instructions: | ||
'Persist your Courier API key into a .courier file in your current working directory', | ||
component: params => { | ||
return <Config params={params} />; | ||
}, | ||
|
@@ -45,7 +48,7 @@ mappings.set('config', { | |
}, | ||
], | ||
example: `courier config --apikey MY_API_KEY`, | ||
noApiKeyRequired: true | ||
noApiKeyRequired: true, | ||
}); | ||
mappings.set('whoami', { | ||
instructions: 'Display the currently authenticated workspace', | ||
|
@@ -132,6 +135,36 @@ mappings.set('track', { | |
return <Track params={params} />; | ||
}, | ||
}); | ||
mappings.set('users:get', { | ||
params: '<user>', | ||
instructions: 'Fetch the data for a given user ID', | ||
example: `courier users:get user123`, | ||
component: params => { | ||
return <UsersGet params={params} />; | ||
}, | ||
}); | ||
mappings.set('users:set', { | ||
params: '<user>', | ||
instructions: "Overwrite a user's profile with the provided data", | ||
options: [ | ||
{ | ||
option: '--email <email address>', | ||
value: '', | ||
}, | ||
{ | ||
option: '--tel <phone number>', | ||
value: '', | ||
}, | ||
{ | ||
option: '--<key> <value>', | ||
value: 'arbitrary key/value properties for your user', | ||
}, | ||
], | ||
example: `courier users:set user123 --email [email protected]`, | ||
component: params => { | ||
return <UsersSet params={params} />; | ||
}, | ||
}); | ||
mappings.set('digests:flush', { | ||
params: '<user> <digest>', | ||
instructions: 'Flush any currently queued events for a given user + digest', | ||
|