Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Update related method to sign up
Browse files Browse the repository at this point in the history
  • Loading branch information
seia-soto committed Feb 16, 2021
1 parent 48b16cc commit a521887
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/api/checkWaitlistStatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import agent from '../structures/agent'

const checkWaitlistStatus = async (profile, name) => {
'use strict'

const response = await agent(
'/check_waitlist_status',
{},
{
...profile,
userId: '(null)'
}
)
const data = await response.json()

return data
}

export default checkWaitlistStatus

export const specification = {
is_onborading: Boolean,
is_waitlisted: Boolean,
success: Boolean
}
10 changes: 9 additions & 1 deletion src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ import updateBio from './updateBio'
import getFollowers from './getFollowers'
import getFollowings from './getFollowings'
import updateAvatar from './updateAvatar'
import checkWaitlistStatus from './checkWaitlistStatus'
import recordActionTrails from './recordActionTrails'
import updateName from './updateName'
import updateUsername from './updateUsername'

// NOTE: Externals
import getStatic from './getStatic'
Expand Down Expand Up @@ -89,5 +93,9 @@ export {
updateBio,
getFollowers,
getFollowings,
updateAvatar
updateAvatar,
checkWaitlistStatus,
recordActionTrails,
updateName,
updateUsername
}
42 changes: 42 additions & 0 deletions src/api/recordActionTrails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { v4 as uuidv4 } from 'uuid'

import agent from '../structures/agent'

const recordActionTrails = async (profile, opts) => {
'use strict'

opts = opts || {}

opts.type = opts.type || 'app_opened'
opts.date = opts.date || Math.floor(Date.now() / 1000) + '.' + Math.random().toString(10).slice(-6) // NOTE: e.g. 1613453171.505264;
opts.eventId = (opts.eventId || uuidv4()).toUpperCase()

const response = await agent(
'/record_action_trails',
{
body: {
action_trails: [
{
blob_data: {
client_event_id: opts.eventId,
client_time_recorded: opts.date
},
client_event_id: opts.eventId,
client_time_created: opts.date,
trail_type: opts.type
}
]
}
},
profile
)
const data = await response.json()

return data
}

export default recordActionTrails

export const specification = {
success: Boolean
}
25 changes: 25 additions & 0 deletions src/api/updateName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import agent from '../structures/agent'

const updateName = async (profile, name) => {
'use strict'

const response = await agent(
'/update_name',
{
body: {
name: name || null // NOTE: String in `${firstName} ${lastName}` format.
}
},
profile
)
const data = await response.json()

return data
}

export default updateName

export const specification = {
error_message: String,
success: Boolean
}
27 changes: 27 additions & 0 deletions src/api/updateUsername.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import agent from '../structures/agent'

const updateUsername = async (profile, name) => {
'use strict'

const response = await agent(
'/update_username',
{
body: {
twitter_secret: null,
twitter_token: null,
username: name || null // NOTE: Max 16 character.
}
},
profile
)
const data = await response.json()

return data
}

export default updateUsername

export const specification = {
error_message: String,
success: Boolean
}

0 comments on commit a521887

Please sign in to comment.