profiles

package
v0.0.0-...-c9f6891 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

README

Profile

PANTAHUB User profile

NOTE: Profiles are implicitly created for all accounts

curl --request PUT \
  --url http://localhost:12365/apps/ \
  --header 'authorization: Bearer $TOKEN' \
  --header 'content-type: application/json' \
  --data '{
  "fullName": "Sergio Marin",
  "bio": "Pantacor developer",
  "location": "Santiago, Chile",
  "picture": "base64 encode Image 200x200px",
  "website": "https://highercomve.github.io",
  "github": "https://github.com/highercomve",
  "gitlab": "https://gitlab.com/highercomve",
  "company": "Pantacor",
  "twitter": "https://twitter.com/pantahub",
  "time-created": "2020-10-08T15:29:27.045Z",
  "time-modified": "2020-10-08T15:30:23.489Z"
}'

Get All profiles

http GET localhost:12365/profiles  Authorization:"Bearer $TOKEN"

HTTP/1.1 200 OK
Content-Length: 331
Content-Type: application/json; charset=utf-8
Date: Wed, 12 Jul 2017 21:13:08 GMT
X-Powered-By: go-json-rest

[
    {
        "nick": "efg",
        "bio": "",
        "public": false,
        "garbage": false,
        "time-created": "0001-01-01T00:00:00Z",
        "time-modified": "0001-01-01T00:00:00Z"
    },
    {
        "nick": "abc",
        "bio": "",
        "public": false,
        "garbage": false,
        "time-created": "0001-01-01T00:00:00Z",
        "time-modified": "0001-01-01T00:00:00Z"
    }
]

Get All profiles having nick starts with abc

http GET localhost:12365/profiles?nick=^abc  Authorization:"Bearer $TOKEN"

HTTP/1.1 200 OK
Content-Length: 331
Content-Type: application/json; charset=utf-8
Date: Wed, 12 Jul 2017 21:13:08 GMT
X-Powered-By: go-json-rest

[
    {
        "nick": "abc",
        "bio": "",
        "public": false,
        "garbage": false,
        "time-created": "0001-01-01T00:00:00Z",
        "time-modified": "0001-01-01T00:00:00Z"
    }
]

Get a profiles by user ID

http GET localhost:12365/profiles/pantahub-ci  Authorization:"Bearer $TOKEN"

HTTP/1.1 200 OK
Content-Length: 331
Content-Type: application/json; charset=utf-8
Date: Wed, 12 Jul 2017 21:13:08 GMT
X-Powered-By: go-json-rest

 {
        "nick": "abc",
        "bio": "",
        "public": false,
        "garbage": false,
        "time-created": "0001-01-01T00:00:00Z",
        "time-modified": "0001-01-01T00:00:00Z"
 }

Using Pagination(By default page=0 & limit=20)

http GET localhost:12365/profiles/?page=3&limit=2  Authorization:"Bearer $TOKEN"

HTTP/1.1 200 OK
Content-Length: 331
Content-Type: application/json; charset=utf-8
Date: Wed, 12 Jul 2017 21:13:08 GMT
X-Powered-By: go-json-rest

[
    {
        "nick": "efg",
        "bio": "",
        "public": false,
        "garbage": false,
        "time-created": "0001-01-01T00:00:00Z",
        "time-modified": "0001-01-01T00:00:00Z"
    },
    {
        "nick": "abc",
        "bio": "",
        "public": false,
        "garbage": false,
        "time-created": "0001-01-01T00:00:00Z",
        "time-modified": "0001-01-01T00:00:00Z"
    }
]

Documentation

Index

Constants

View Source
const CollectionName = "pantahub_profiles"

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	API *rest.Api
	// contains filtered or unexported fields
}

App define a new rest application for profiles

func New

func New(jwtMiddleware *jwt.JWTMiddleware,
	mongoClient *mongo.Client) *App

New create a profiles rest application

func (*App) ExistsInProfiles

func (a *App) ExistsInProfiles(parentCtx context.Context, ID primitive.ObjectID) (bool, error)

ExistsInProfiles : Check if a user details exists in profiles or not

func (*App) HavePublicDevices

func (a *App) HavePublicDevices(parentCtx context.Context, prn string) (bool, error)

HavePublicDevices : Check if a user have public devices or not

func (*App) MakeUserProfile

func (a *App) MakeUserProfile(parentCtx context.Context, account *accounts.Account, newProfile *UpdateableProfile) (*Profile, error)

MakeUserProfile : Make User Profile from account

func (*App) MarkProfileAsPrivate

func (a *App) MarkProfileAsPrivate(parentCtx context.Context, prn string) error

MarkProfileAsPrivate : Mark Profile As Private

type ModelError

type ModelError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ModelError error type

type Profile

type Profile struct {
	ID    primitive.ObjectID `json:"-" bson:"_id"`
	Prn   string             `json:"-" bson:"prn"`
	Nick  string             `json:"nick" bson:"-"`
	Email string             `json:"email" bson:"-"`

	*UpdateableProfile `json:",inline" bson:",inline"`
	Meta               map[string]interface{} `json:"meta" bson:"meta"`

	Public  bool `json:"-" bson:"public"`
	Garbage bool `json:"-" bson:"garbage"`

	TimeCreated  time.Time `json:"time-created,omitempty" bson:"time-created"`
	TimeModified time.Time `json:"time-modified,omitempty" bson:"time-modified"`
}

Profile : Public information for one account

type UpdateableProfile

type UpdateableProfile struct {
	FullName string `json:"fullName" bson:"full-name"`
	Bio      string `json:"bio" bson:"bio"`
	Picture  string `json:"picture" bson:"picture"`
	Website  string `json:"website" bson:"website"`
	Location string `json:"location" bson:"location"`
	Github   string `json:"github" bson:"github"`
	Gitlab   string `json:"gitlab" bson:"gitlab"`
	Company  string `json:"company" bson:"company"`
	Twitter  string `json:"twitter" bson:"twitter"`
}

UpdateableProfile updateable part of a Profile

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL