rpc

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: GPL-2.0, GPL-3.0 Imports: 25 Imported by: 0

README

Package RPC

The rpc package contains API routes that are served when the opensolar platform is run

Documentation

API Documentation is provided via slate and can be accessed over at https://github.com/YaleOpenLab/openx-apidocs

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AdminRPC = map[int][]string{
	1: {"/admin/flag", "GET", "projIndex"},
	2: {"/admin/getallprojects", "GET"},
	3: {"/admin/getrecipient", "GET", "index"},
	4: {"/admin/getinvestor", "GET", "index"},
	5: {"/admin/getentity", "GET", "index"},
	6: {"/admin/getallinvestors", "GET"},
	7: {"/admin/getallrecipients", "GET"},
	8: {"/admin/project/complete", "POST", "index"},
	9: {"/admin/project/featured", "POST", "index"},
}

AdminRPC is a list of all the endpoints that can be called by admins

View Source
var DevRPC = map[int][]string{
	1: {"/developer/withdraw", "POST", "amount", "projIndex"},
	2: {"/developer/dashboard", "GET"},
	3: {"/developer/money/request", "GET", "index", "amount"},
}

DevRPC contains a list of all the developer rpc endpoints

View Source
var EntityRPC = map[int][]string{
	1: {"/entity/validate", "GET"},
	2: {"/entity/stage0", "GET"},
	3: {"/entity/stage1", "GET"},
	4: {"/entity/stage2", "GET"},
	5: {"/entity/addcollateral", "POST", "amount", "collateral"},
	6: {"/entity/proposeproject/opensolar", "POST", "projIndex", "fee"},
	7: {"/entity/register", "POST", "name", "username", "pwhash", "token", "seedpwd", "entityType"},
	8: {"/entity/contractor/dashboard", "GET"},
}

EntityRPC is a list of endpoints that can be called by an entity

View Source
var GuaRPC = map[int][]string{
	1: {"/guarantor/deposit/xlm", "POST", "amount", "projIndex", "seedpwd"},
	2: {"/guarantor/deposit/asset", "POST", "amount", "projIndex", "seedpwd", "assetCode"},
}

GuaRPC contains a list of all guarantor related RPC endpoints

View Source
var InvRPC = map[int][]string{
	1:  {"/investor/register", "POST", "name", "username", "pwhash", "token", "seedpwd"},
	2:  {"/investor/validate", "GET"},
	3:  {"/investor/all", "GET"},
	4:  {"/investor/invest", "POST", "seedpwd", "projIndex", "amount"},
	5:  {"/investor/vote", "POST", "votes", "projIndex"},
	6:  {"/investor/localasset", "POST", "assetName"},
	7:  {"/investor/sendlocalasset", "POST", "assetName", "seedpwd", "destination", "amount"},
	8:  {"/investor/sendemail", "POST", "message", "to"},
	9:  {"/investor/dashboard", "GET"},
	10: {"/investor/company/set", "POST"},
	11: {"/investor/company/details", "POST", "companytype",
		"name", "legalname", "address", "country", "city", "zipcode", "role"},
}

InvRPC contains a list of all investor related endpoints

View Source
var ParticleRPC = map[int][]string{
	1:  {"/particle/devices", "GET", "accessToken"},
	2:  {"/particle/productinfo", "GET", "accessToken", "productInfo"},
	3:  {"/particle/deviceinfo", "GET", "accessToken", "deviceId"},
	4:  {"/particle/deviceping", "GET", "accessToken", "deviceId"},
	5:  {"/particle/devicesignal", "GET", "signal", "accessToken"},
	6:  {"/particle/getdeviceid", "GET", "serialNumber", "accessToken"},
	7:  {"/particle/diag/last", "GET", "accessToken", "deviceId"},
	8:  {"/particle/diag/all", "GET", "accessToken", "deviceId"},
	9:  {"/particle/user/info", "GET", "accessToken"},
	10: {"/particle/sims", "GET", "accessToken"},
}

ParticleRPC contains a list of all particle related endpoints

View Source
var ProjectRPC = map[int][]string{
	2:  {"/project/all", "GET"},
	3:  {"/project/get", "GET", "index"},
	4:  {"/projects", "GET", "stage"},
	5:  {"/utils/addhash", "GET", "projIndex", "choice", "choicestr"},
	6:  {"/tellershutdown", "GET", "projIndex", "deviceId", "tx1", "tx2"},
	7:  {"/tellerpayback", "GET", "deviceId", "projIndex"},
	8:  {"/project/get/dashboard", "GET", "index"},
	9:  {"/explore", "GET"},
	10: {"/project/detail", "GET", "index"},
	11: {"/project/active", "GET"},
	12: {"/project/complete", "GET"},
	13: {"/project/featured", "GET"},
}

ProjectRPC contains a list of all the project related RPC endpoints

View Source
var PublicRPC = map[int][]string{
	1: {"/public/investor/all"},
	2: {"/public/recipient/all"},
	3: {"/public/recipient/reputation/top"},
	4: {"/public/investor/reputation/top"},
}

PublicRPC contains a list of all public RPC endpoints

View Source
var RecpRPC = map[int][]string{
	1:  {"/recipient/all", "GET"},
	2:  {"/recipient/register", "POST", "name", "username", "pwhash", "seedpwd"},
	3:  {"/recipient/validate", "GET"},
	4:  {"/recipient/payback", "POST", "assetName", "amount", "seedpwd", "projIndex"},
	5:  {"/recipient/deviceId", "POST", "deviceId"},
	6:  {"/recipient/startdevice", "POST", "start"},
	7:  {"/recipient/storelocation", "POST", "location"},
	8:  {"/recipient/auction/choose/blind", "GET"},
	9:  {"/recipient/auction/choose/vickrey", "GET"},
	10: {"/recipient/auction/choose/time", "GET"},
	11: {"/recipient/unlock/opensolar", "POST", "seedpwd", "projIndex"},
	12: {"/recipient/addemail", "POST", "email"},
	13: {"/recipient/finalize", "POST", "projIndex"},
	14: {"/recipient/originate", "POST", "projIndex"},
	15: {"/recipient/trustlimit", "GET", "assetName"},
	16: {"/recipient/ssh", "POST", "hash"},
	17: {"/recipient/onetimeunlock", "POST", "projIndex", "seedpwd"},
	18: {"/recipient/register/teller", "POST", "url", "projIndex"},
	19: {"/recipient/teller/details", "POST", "projIndex", "url", "brokerurl", "topic"},
	20: {"/recipient/dashboard", "GET"},
	21: {"/recipient/company/set", "POST"},
	22: {"/recipient/company/details", "POST", "companytype", "name", "legalname", "address", "country", "city", "zipcode", "role"},
	23: {"/recipient/teller/energy", "POST", "energy"},
}

RecpRPC is a collection of all recipient RPC endpoints and their required params

View Source
var StagesRPC = map[int][]string{
	1: {"/stages/all", "GET"},
	2: {"/stages", "GET", "index"},
	3: {"/stages/promote", "GET", "index"},
}

StagesRPC is a list of all stage related RPC endpoints

View Source
var UserRPC = map[int][]string{
	1: {"/update", "POST"},
	2: {"/user/report", "POST", "projIndex"},
	3: {"/user/info", "GET"},
	4: {"/user/register", "POST", "email", "username", "pwhash", "seedpwd"},
	5: {"/user/roles", "GET"},
}

UserRPC is a collection of all user RPC endpoints and their required params

Functions

func InvValidateHelper

func InvValidateHelper(w http.ResponseWriter, r *http.Request, options []string, method string) (core.Investor, error)

InvValidateHelper is a helper that validates an investor and returns the investor struct if successful

func StartServer

func StartServer(portx int, insecure bool)

StartServer starts the opensolar backend server

Types

type ExplorePageStub

type ExplorePageStub struct {
	StageDescription interface{}
	Name             interface{}
	Location         interface{}
	ProjectType      interface{}
	OriginatorName   interface{}
	Description      interface{}
	Bullet1          interface{}
	Bullet2          interface{}
	Bullet3          interface{}
	Solar            interface{}
	Storage          interface{}
	Tariff           interface{}
	Return           interface{}
	Rating           interface{}
	Tax              interface{}
	Acquisition      interface{}
	MainImage        interface{}
	Stage            int
	Index            int
	Raised           float64
	Total            float64
	Backers          int
}

ExplorePageStub is used to show brief descriptions of the project on the frontend's explore page

type GetAccessTokenData

type GetAccessTokenData struct {
	Data []getAccessTokenDataHelper `json:"data"`
}

GetAccessTokenData is a helper struct for the swytch API

type GetAssetStruct

type GetAssetStruct struct {
	Data []gA2 `json:"data"`
}

GetAssetStruct is a helper struct for the swytch API

type GetEnergyAttributionData

type GetEnergyAttributionData struct {
	Data []getEnergyAttributionHelper `json:"data"`
}

GetEnergyAttributionData is a helper struct for the swytch API

type GetEnergyStruct

type GetEnergyStruct struct {
	Data []getEnergyHelper `json:"data"`
}

GetEnergyStruct is a helper struct for the swytch API

type GetSwytchUserStruct

type GetSwytchUserStruct struct {
	Data []getSwytchUserStructHelper `json:"data"`
}

GetSwytchUserStruct is a helper struct for the swytch API

type LenReturn

type LenReturn struct {
	Length int
}

LenReturn is the length return structure

type ParticleDevice

type ParticleDevice struct {
	ID                    string `json:"id"`
	Name                  string `json:"name"`
	LastApp               string `json:"last_app"`
	LastIPAddress         string `json:"last_ip_address"`
	ProductID             int    `json:"product_id"`
	Connected             bool   `json:"connected"`
	PlatformID            int    `json:"platform_id"`
	Cellular              bool   `json:"cellular"`
	Notes                 string `json:"notes"`
	Status                string `json:"status"`
	SerialNumber          string `json:"serial_number"`
	CurrentBuildTarget    string `json:"current_build_target"`
	SystemFirmwareVersion string `json:"system_firmware_version"`
	DefaultBuildTarget    string `json:"default_build_target"`
}

ParticleDevice is a structure to parse the returned particle.io data

type ParticleEventStream

type ParticleEventStream struct {
	Data        string `json:"data"`
	TTL         string `json:"ttl"`
	PublishedAt string `json:"published_at"`
	Coreid      string `json:"coreid"`
}

ParticleEventStream is a structure to parse returned particle.io data

type ParticlePingResponse

type ParticlePingResponse struct {
	Online bool `json:"online"`
	Ok     bool `json:"ok"`
}

ParticlePingResponse is a structure to parse returned particle.io data

type ParticleProductDevice

type ParticleProductDevice struct {
	ID                             string   `json:"id"`
	ProductID                      int      `json:"product_id"`
	LastIPAddress                  string   `json:"last_ip_address"`
	LastHandshakeAt                string   `json:"last_handshake_at"`
	UserID                         string   `json:"user_id"`
	Online                         bool     `json:"online"`
	Name                           string   `json:"name"`
	PlatformID                     int      `json:"platform_id"`
	FirmwareProductID              int      `json:"firmware_product_id"`
	Quarantined                    bool     `json:"quarantined"`
	Denied                         bool     `json:"denied"`
	Development                    bool     `json:"development"`
	Groups                         []string `json:"groups"`
	TargetedFirmwareReleaseVersion string   `json:"targeted_firmware_release_version"`
	SystemFirmwareVersion          string   `json:"system_firmware_version"`
	SerialNumber                   string   `json:"serial_number"`
	Owner                          string   `json:"owner"`
}

ParticleProductDevice is a structure to parse returned particle.io data

type ParticleProductInfo

type ParticleProductInfo struct {
	Devices []ParticleProductDevice
}

ParticleProductInfo is a structure to parse returned particle.io data

type ParticleUser

type ParticleUser struct {
	Username        string   `json:"username"`
	SubscriptionIds []string `json:"subscription_ids"`
	AccountInfo     struct {
		FirstName       string `json:"first_name"`
		LastName        string `json:"last_name"`
		CompanyName     string `json:"company_name"`
		BusinessAccount bool   `json:"business_account"`
	} `json:"account_info"`
	TeamInvites         []string `json:"team_invites"`
	WifiDeviceCount     int      `json:"wifi_device_count"`
	CellularDeviceCount int      `json:"cellular_device_count"`
}

ParticleUser is a structure to parse returned particle.io data

type SerialNumberResponse

type SerialNumberResponse struct {
	Ok         bool   `json:"ok"`
	DeviceID   string `json:"device_id"`
	PlatformID int    `json:"platform_id"`
}

SerialNumberResponse is a structure to parse returned particle.io data

type SignalResponse

type SignalResponse struct {
	ID        string `json:"id"`
	Connected bool   `json:"connected"`
	Signaling bool   `json:"signaling"`
}

SignalResponse is a structure to parse returned particle.io data

type SnInvestor

type SnInvestor struct {
	Name                  string
	InvestedSolarProjects []string
	AmountInvested        float64
	InvestedBonds         []string
	InvestedCoops         []string
	PublicKey             string
	Reputation            float64
}

SnInvestor defines a sanitized investor

type SnRecipient

type SnRecipient struct {
	Name                  string
	PublicKey             string
	ReceivedSolarProjects []string
	Reputation            float64
}

SnRecipient defines a sanitized recipient

type SnUser

type SnUser struct {
	Name       string
	PublicKey  string
	Reputation float64
}

SnUser defines a sanitized user

type UserRoleStruct

type UserRoleStruct struct {
	User      openx.User
	Investor  core.Investor
	Recipient core.Recipient
	Entity    core.Entity
}

UserRoleStruct is a handler used to return /user/validate

Jump to

Keyboard shortcuts

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