goparse

package module
v0.0.0-...-b380d88 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2016 License: MIT Imports: 9 Imported by: 0

README

goparse

Build Status Coverage License

Goparse is a client library to access Parse REST API.

Installation

go get github.com/dogenzaka/goparse

Quick start

To create a session from default client,

import(
  "github.com/dogenzaka/goparse"
)

func main() {

  parseSession := goparse.NewSession("SESSION_TOKEN")
  me, err := parseSession.GetMe()
  ..

}

Custom Client

To create a configured` client,

parseClient := goparse.NewClient(goparse.Config({
  ApplicationId: "PARSE_APPLICATION_ID",
  RestAPIKey: "PARSE_REST_API_KEY",
  MasterKey: "PARSE_MASTER_KEY",
  EndPointURL: "PARSE_ENDPOINT_URL"
})

parseSession := parseClient.NewSession()
me, err := parseSession.GetMe()
..

Environment variables

The default client uses environment variables to access Parse REST API.

  • PARSE_APPLICATION_ID
  • PARSE_REST_API_KEY
  • PARSE_MASTER_KEY
  • PARSE_ENDPOINT_URL

License

Goparse is licensed under the MIT.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrObjectNotFound Error code indicating the specified object doesn't exist.
	ErrObjectNotFound = errors.New("object not found")
)

Functions

func IsObjectNotFound

func IsObjectNotFound(err error) bool

IsObjectNotFound check the error "not found" or not

Types

type Anonymous

type Anonymous struct {
	ID string `json:"id,omitempty"`
}

Anonymous data type

type AuthData

type AuthData struct {
	Facebook  *Facebook  `json:"facebook,omitempty"`
	Twitter   *Twitter   `json:"twitter,omitempty"`
	Anonymous *Anonymous `json:"anonymous,omitempty"`
}

AuthData data type

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"error"`
}

Error data type

func (*Error) Error

func (err *Error) Error() string

Error to string

type Facebook

type Facebook struct {
	ID          string    `json:"id,omitempty"`
	AccessToken string    `json:"access_token,omitempty"`
	Expiration  time.Time `json:"expiration_date,omitempty"`
}

Facebook data type

type Installation

type Installation struct {
	ObjectID       string    `json:"objectId,omitempty"`
	GCMSenderID    string    `json:"GCMSenderID,omitempty"`
	AppIdentifier  string    `json:"appIdentifier,omitempty"`
	AppName        string    `json:"appName,omitempty"`
	AppVersion     string    `json:"appVersion,omitempty"`
	Badge          string    `json:"badge,omitempty"`
	Channels       []string  `json:"channels,omitempty"`
	DeviceToken    string    `json:"deviceToken,omitempty"`
	DeviceType     string    `json:"deviceType,omitempty"`
	InstallationID string    `json:"installationId,omitempty"`
	ParseVersion   string    `json:"parseVersion,omitempty"`
	PushType       string    `json:"pushType,omitempty"`
	TimeZone       string    `json:"timeZone,omitempty"`
	User           Pointer   `json:"user,omitempty"`
	CreatedAt      time.Time `json:"createdAt,omitempty"`
	UpdatedAt      time.Time `json:"updatedAt,omitempty"`
}

Installation data type

type ObjectResponse

type ObjectResponse struct {
	ObjectID  string    `json:"objectId,omitempty"`
	CreatedAt time.Time `json:"createdAt,omitempty"`
	UpdatedAt time.Time `json:"updatedAt,omitempty"`
}

ObjectResponse data type

type ParseClass

type ParseClass struct {
	Session   *ParseSession
	Name      string
	ClassURL  string
	UseMaster bool
}

ParseClass is an object that contains the ParseSession

func (*ParseClass) Create

func (c *ParseClass) Create(data interface{}, result interface{}) error

Create creates class from data

func (*ParseClass) Delete

func (c *ParseClass) Delete(objectID string) error

Delete deletes class by ID

func (*ParseClass) Select

func (c *ParseClass) Select(objectID string, result interface{}) error

Select gets class data information

func (*ParseClass) SelectQuery

func (c *ParseClass) SelectQuery(query map[string]interface{}, result interface{}) error

Select gets class data information by custom query

func (*ParseClass) Update

func (c *ParseClass) Update(objectID string, data interface{}, result interface{}) error

Update updates class by ID

type ParseClient

type ParseClient struct {
	URL           string
	ApplicationID string
	RESTAPIKey    string
	MasterKey     string
	TimeOut       time.Duration
}

ParseClient is the client to access Parse REST API

func NewClient

func NewClient() (*ParseClient, error)

NewClient is creating ParseClient

func NewClientWithConfig

func NewClientWithConfig(config ParseConfig) (*ParseClient, error)

NewClientWithConfig creates Parse Client with configuration

func (*ParseClient) NewSession

func (p *ParseClient) NewSession(sessionToken string) *ParseSession

NewSession creates a new session from the client

type ParseConfig

type ParseConfig struct {
	URL           string
	ApplicationID string
	RESTAPIKey    string
	MasterKey     string
	TimeOut       time.Duration
}

ParseConfig is the configuration for initializing ParseClient

type ParseSession

type ParseSession struct {
	SessionToken string
	// contains filtered or unexported fields
}

ParseSession is the client which has SessionToken as user authentication.

func NewSession

func NewSession(sessionToken string) (*ParseSession, error)

NewSession create a new session from default client

func (*ParseSession) DeleteUser

func (s *ParseSession) DeleteUser(userID string) error

DeleteUser deletes user by ID

func (*ParseSession) GetMe

func (s *ParseSession) GetMe() (user User, err error)

GetMe gets self user information

func (*ParseSession) GetMeInto

func (s *ParseSession) GetMeInto(user interface{}) error

GetMeInto gets self user information into provided object

func (*ParseSession) GetUser

func (s *ParseSession) GetUser(userObjectID string) (user User, err error)

GetUser gets user information

func (*ParseSession) GetUserByMaster

func (s *ParseSession) GetUserByMaster(userObjectID string) (user User, err error)

GetUserByMaster gets user information by use master key

func (*ParseSession) GetUserInto

func (s *ParseSession) GetUserInto(userObjectID string, user interface{}) (err error)

GetUserInto gets user information into provided object

func (*ParseSession) GetUserIntoByMaster

func (s *ParseSession) GetUserIntoByMaster(userObjectID string, user interface{}) (err error)

GetUserIntoByMaster gets user information into provided object by use master key

func (*ParseSession) Login

func (s *ParseSession) Login(username string, password string) (user User, err error)

Login with data

func (*ParseSession) NewClass

func (s *ParseSession) NewClass(className string) *ParseClass

NewClass creates a new class from the session

func (*ParseSession) PushNotification

func (s *ParseSession) PushNotification(body PushNotificationQuery) error

PushNotification sends push-notifiaction each device via parse

func (*ParseSession) PushNotificationByMaster

func (s *ParseSession) PushNotificationByMaster(body PushNotificationQuery) error

PushNotificationByMaster sends push-notifiaction as Master to each device via parse

func (*ParseSession) Signup

func (s *ParseSession) Signup(data interface{}) (user User, err error)

Signup new user

func (*ParseSession) UpdateUser

func (s *ParseSession) UpdateUser(userObjectID string, data interface{}) (*ObjectResponse, error)

UpdateUser update user information

func (*ParseSession) UpdateUserByMaster

func (s *ParseSession) UpdateUserByMaster(userObjectID string, data interface{}) (*ObjectResponse, error)

UpdateUserByMaster update user information by use master key

func (*ParseSession) UploadInstallation

func (s *ParseSession) UploadInstallation(data Installation, result interface{}) error

UploadInstallation stores the subscription data for installations

type Pointer

type Pointer struct {
	Type      string `json:"__type"`
	ClassName string `json:"className"`
	ObjectID  string `json:"objectId"`
}

Pointer data type

type PushNotificationQuery

type PushNotificationQuery struct {
	Where              map[string]interface{} `json:"where"`
	PushTime           interface{}            `json:"push_time,omitempty"`
	ExpirationTime     interface{}            `json:"expiration_time,omitempty"`
	ExpirationInterval int64                  `json:"expiration_interval,omitempty"`
	Data               interface{}            `json:"data"`
}

PushNotificationQuery data type. You can set the push_time and expiration_time to either "2015-08-022T12:00:00.000Z" or 1440226800.

type Signup

type Signup struct {
	UserName string    `json:"username"`
	Password string    `json:"password"`
	AuthData *AuthData `json:"authData,omitempty"`
}

Signup data type

type Twitter

type Twitter struct {
	ID              string `json:"id,omitempty"`
	ScreenName      string `json:"screen_name,omitempty"`
	ConsumerKey     string `json:"consumer_key,omitempty"`
	ConsumerSecret  string `json:"consumer_secret,omitempty"`
	AuthToken       string `json:"auth_token,omitempty"`
	AuthTokenSecret string `json:"auth_token_secret,omitempty"`
}

Twitter data type

type User

type User struct {
	ObjectID      string    `json:"objectId,omitempty"`
	Email         string    `json:"email,omitempty"`
	UserName      string    `json:"username,omitempty"`
	Phone         string    `json:"phone,omitempty"`
	EmailVerified bool      `json:"emailVerified,omitempty"`
	SessionToken  string    `json:"sessionToken,omitempty"`
	AuthData      *AuthData `json:"authData,omitempty"`
	CreatedAt     time.Time `json:"createdAt,omitempty"`
	UpdatedAt     time.Time `json:"updatedAt,omitempty"`
}

User data type

Jump to

Keyboard shortcuts

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