Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Latest commit

 

History

History
609 lines (369 loc) · 17.8 KB

README.md

File metadata and controls

609 lines (369 loc) · 17.8 KB

Circles Api Chat Server Backers Follow Circles Circles License

This holds the offchain components of the Circles API

Setup

# clone and set up submodules
git clone
cd circles-api
git submodule update --init

# install
npm install

# install contracts
cd contracts
npm install

# set up blockchain
npm run ganache

# deploy contracts
npx truffle compile
  npx truffle migrate --reset --compile-all

# use truffle console
npx truffle console
> let hf = await HubFactory.deployed()
> let s = await hf.spawn(1736111111111111, 0, 'CRC', 3600, 100)

Development

// hotreloading should work
npm run dev

Env Vars

Get in touch with @ana0 or @edzillion to get these env vars.

# General
LOG_LEVEL=debug
NODE_ENV=test
API_VERSION=v1.1.2

# Cognito
COGNITO_POOL_ID=
COGNITO_POOL_REGION=
COGNITO_CLIENT_ID_API=
COGNITO_CLIENT_ID_MOBILE=
COGNITO_TEST_USERNAME=
COGNITO_TEST_PASSWORD=
COGNITO_POOL_JWT_KID=
COGNITO_POOL_JWT_N=

# SNS
ANDROID_GCM_PLATFORM_ARN=

# Database
PGUSER=
PGPASSWORD=
PGHOST=
PGPORT=
PGDATABASE=

# Blockchain
NETWORK_ID=
HUB_CONTRACT_ADDRESS=
PRIVATE_KEY=

# For scripts
AWS_REGION=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AUTH_ACCESS_TOKEN= //generated by saveCognitoTokenToEnvFile.js

Authentication

Api authenication is managed by accesstoken sent in the response headers npm run token will generate a valid token


user-profile-service v1.1.2

CRUD app for user and organization profiles

Notifs

Delete User's own Notification

Back to top

DELETE /notifs/:notifId

Parameter Parameters

Name Type Description
notifId Number

Notification Id.

Success 200

Name Type Description
None

Returns nothing on success.

Request all User's own Notifications

Back to top

GET /notifs/

Success 200

Name Type Description
created_at Date

Record creation date.

description String

Notification text.

dismissed Boolean

Has this Notification been dismissed?

id Number

Id of the Notification (ascending integer).

owner_id String

User Id of the Notification owner.

updated_at Date

Record update date.

Update User's own Notification

Back to top

PUT /notifs/:notifId

Parameter Parameters

Name Type Description
notifId Number

Notification Id.

Success 200

Name Type Description
created_at Date

Record creation date.

description String

Notification text.

dismissed Boolean

Has this Notification been dismissed?

id Number

Id of the Notification (ascending integer).

owner_id String

User Id of the Notification owner.

updated_at Date

Record update date.

Offers

Delete User's own Offer

Back to top

DELETE /offers/:offerId

Parameter Parameters

Name Type Description
offerId Number

Offer Id.

Success 200

Name Type Description
None

Returns nothing on success.

Request all Offers

Back to top

GET /offers/

Success 200

Name Type Description
amount Number

The amount of an item offered.

category String

The category of item offered.

created_at Date

Record creation date.

description String

Offer description.

id Number

Id of the Offer (ascending integer).

item_code String

Item code for linking with POS systems.

owner_id String

User Id of the Offer owner.

percentage Number

Percentage of Offer to be paid in Circles (multiple of 0.1).

price Number

Price of Offer in Circles (multiple of 0.1).

public Boolean

Is this Offer publicly viewable?

title String

The title of the Offer.

type Enum

The type of Offer {'ITEM', 'PERCENTAGE_ITEM', 'PERCENTAGE_CATEGORY'}.

updated_at Date

Record update date.

Create an Offer

Back to top

POST /offers/

Success 201

Name Type Description
amount Number

The amount of an item offered.

category String

The category of item offered.

created_at Date

Record creation date.

description String

Offer description.

id Number

Id of the Offer (ascending integer).

item_code String

Item code for linking with POS systems.

owner_id String

User Id of the Offer owner.

percentage Number

Percentage of Offer to be paid in Circles (multiple of 0.1).

price Number

Price of Offer in Circles (multiple of 0.1).

public Boolean

Is this Offer publicly viewable?

title String

The title of the Offer.

type Enum

The type of Offer {'ITEM', 'PERCENTAGE_ITEM', 'PERCENTAGE_CATEGORY'}.

updated_at Date

Record update date.

Update User's own Offer

Back to top

PUT /offers/:offerId

Parameter Parameters

Name Type Description
offerId Number

Offer Id.

Success 200

Name Type Description
amount Number

The amount of an item offered.

category String

The category of item offered.

created_at Date

Record creation date.

description String

Offer description.

id Number

Id of the Offer (ascending integer).

item_code String

Item code for linking with POS systems.

owner_id String

User Id of the Offer owner.

percentage Number

Percentage of Offer to be paid in Circles (multiple of 0.1).

price Number

Price of Offer in Circles (multiple of 0.1).

public Boolean

Is this Offer publicly viewable?

title String

The title of the Offer.

type Enum

The type of Offer {'ITEM', 'PERCENTAGE_ITEM', 'PERCENTAGE_CATEGORY'}.

updated_at Date

Record update date.

Orgs

Update User's own Organization

Back to top

DELETE /orgs/:orgId

Parameter Parameters

Name Type Description
orgId String

Organization UUID.

Success 200

Name Type Description
None

Returns nothing on success.

Request User's own Organization

Back to top

GET /orgs/:orgId

Parameter Parameters

Name Type Description
orgId String

Organization UUID.

Success 200

Name Type Description
address String

Organisation address.

agreed_to_disclaimer Boolean

Legal requirement.

created_at Date

Record creation date.

description String

Organization tagline.

email String

Email of the Organization.

id String

UUID of the Organization.

last_active Date

Last date Organization was active.

latitude Float

Latitude of Organization

longitude Float

longitude of Organization

organization_name String

Display name of Organization.

owner_id String

User Id of the Organization owner.

profile_pic_url String

Url of profile pic (stored on S3).

updated_at Date

Record update date.

Request all Organizations

Back to top

GET /orgs/

Success 200

Name Type Description
address String

Organisation address.

agreed_to_disclaimer Boolean

Legal requirement.

created_at Date

Record creation date.

description String

Organization tagline.

email String

Email of the Organization.

id String

UUID of the Organization.

last_active Date

Last date Organization was active.

latitude Float

Latitude of Organization

longitude Float

longitude of Organization

organization_name String

Display name of Organization.

owner_id String

User Id of the Organization owner.

profile_pic_url String

Url of profile pic (stored on S3).

updated_at Date

Record update date.

Create User's own Organization

Back to top

Create Organization record (201) or return if exists (200)

POST /orgs/

Success 200/201

Name Type Description
address String

Organisation address.

agreed_to_disclaimer Boolean

Legal requirement.

created_at Date

Record creation date.

description String

Organization tagline.

email String

Email of the Organization.

id String

UUID of the Organization.

last_active Date

Last date Organization was active.

latitude Float

Latitude of Organization

longitude Float

longitude of Organization

organization_name String

Display name of Organization.

owner_id String

User Id of the Organization owner.

profile_pic_url String

Url of profile pic (stored on S3).

updated_at Date

Record update date.

Update User's own Organization

Back to top

PUT /orgs/:orgId

Parameter Parameters

Name Type Description
orgId String

Organization UUID.

Success 200

Name Type Description
address String

Organisation address.

agreed_to_disclaimer Boolean

Legal requirement.

created_at Date

Record creation date.

description String

Organization tagline.

email String

Email of the Organization.

id String

UUID of the Organization.

last_active Date

Last date Organization was active.

latitude Float

Latitude of Organization

longitude Float

longitude of Organization

organization_name String

Display name of Organization.

owner_id String

User Id of the Organization owner.

profile_pic_url String

Url of profile pic (stored on S3).

updated_at Date

Record update date.

Users

Delete User's own record

Back to top

DELETE /users/

Success 200

Name Type Description
None

Returns nothing on success.

Get a list of suggested Circles contacts

Back to top

POST /users/contacts

Success 200

Name Type Description
contacts Object[]

List of contacts that are Circles users.

     contacts.id String

Phone specific contact Id.

     contacts.number String

Phone number of contact.

Request User's own record

Back to top

GET /users/

Success 200

Name Type Description
agreed_to_disclaimer Boolean

Legal requirement.

created_at Date

Record creation date.

device_endpoint String

Notification endpoint.

device_id String

Device Id of phone.

display_name String

Full name of the User.

email String

Email of the User.

id String

UUID of the User.

phone_number String

Phone number of the User.

profile_pic_url String

Url of profile pic (stored on S3).

updated_at Date

Record update date.

username String

Username of the User.

Create User's own record

Back to top

Create User record (201) or return if exists (200)

POST /users/

Success 200/201

Name Type Description
agreed_to_disclaimer Boolean

Legal requirement.

created_at Date

Record creation date.

device_endpoint String

Notification endpoint.

device_id String

Device Id of phone.

display_name String

Full name of the User.

email String

Email of the User.

id String

UUID of the User.

phone_number String

Phone number of the User.

profile_pic_url String

Url of profile pic (stored on S3).

updated_at Date

Record update date.

username String

Username of the User.

Update User's own record

Back to top

PUT /users/

Success 200

Name Type Description
agreed_to_disclaimer Boolean

Legal requirement.

created_at Date

Record creation date.

device_endpoint String

Notification endpoint.

device_id String

Device Id of phone.

display_name String

Full name of the User.

email String

Email of the User.

id String

UUID of the User.

phone_number String

Phone number of the User.

profile_pic_url String

Url of profile pic (stored on S3).

updated_at Date

Record update date.

username String

Username of the User.