HologramGo

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2017 License: MIT Imports: 12 Imported by: 0

README

#Hologram-Go-Library

Go Report Card Build Status

Introduction

This is a library built for using our REST APIs.

Installation

One nice thing about Go is how easy it is to work with packages. First, run:

go get github.com/hologram-io/hologram-go

All you need to do after that is add this snippet of code in your source:

import (
	<your other imports go here>
	"github.com/hologram-io/hologram-go"
	<your other imports go here>
)

in your main folder.

Unit Tests

Yay! you're ready for some good testing. All of the test cases are located in the top test directory. Mocked data (in JSON) are in the test/json directory. To run a unit test, just type:

go test <whichever test here>

Support

Please feel free to reach out to us if you have any questions/concerns.

Credits

Special thanks to the amazing work that @kurrik put in his twittergo library. The Errors and Parse interface/functions were taken from there and modified for our needs.

Documentation

Index

Constants

View Source
const (
	STATUS_OK           = 200
	STATUS_CREATED      = 201
	STATUS_ACCEPTED     = 202
	STATUS_NO_CONTENT   = 204
	STATUS_INVALID      = 400
	STATUS_UNAUTHORIZED = 401
	STATUS_FORBIDDEN    = 403
	STATUS_NOTFOUND     = 404
	STATUS_LIMIT        = 429
	STATUS_GATEWAY      = 502
)

HTTP status codes

View Source
const HOLOGRAM_REST_API_BASEURL = "https://dashboard.hologram.io/api/1"

Variables

This section is empty.

Functions

func InitializeUsernameAndPassword

func InitializeUsernameAndPassword(credentialFile string)

REQUIRES: User's username and password. EFFECTS: Initializes the user's username and password state to be used in each

basic authenticated API call.

Types

type Device

type Device map[string]interface{}

Device object returned in the response.

func ClaimOwnershipAndActivateDevice

func ClaimOwnershipAndActivateDevice(simnumber int) Device

ClaimOwnershipAndActivateDevice claims ownership and activate the given device.

func GetDevice

func GetDevice(deviceid int) Device

GetDevice returns a device detail based on the given deviceid.

func PurchaseAndAssignPhoneNumberToDevice

func PurchaseAndAssignPhoneNumberToDevice(deviceid int) Device

PurchaseAndAssignPhoneNumberToDevice purchases and assigns a phone number to the device.

func (Device) GetDeviceId

func (device Device) GetDeviceId() float64

GetDeviceId returns the id.

func (Device) GetDeviceName

func (device Device) GetDeviceName() string

GetDeviceName returns the device name.

func (Device) GetDeviceType

func (device Device) GetDeviceType() string

GetDeviceType returns the device type.

func (Device) GetDeviceUserId

func (device Device) GetDeviceUserId() float64

GetDeviceUserId returns the user id.

func (Device) GetPhoneNumber

func (device Device) GetPhoneNumber() string

GetPhoneNumber returns a phone number.

func (Device) GetTunnelable

func (device Device) GetTunnelable() bool

GetTunnelable returns true if it is tunnelable.

func (Device) GetWhenCreated

func (device Device) GetWhenCreated() string

GetWhenCreated returns a UNIX timestamp of the creation time.

type Devices

type Devices []interface{}

Devices is just a list of Device(s).

func GetDevices

func GetDevices() Devices

GetDevices returns device details.

type Error

type Error map[string]interface{}

func (Error) Code

func (e Error) Code() int64

func (Error) Error

func (e Error) Error() string

func (Error) Message

func (e Error) Message() string

type Errors

type Errors map[string]interface{}

func (Errors) Error

func (e Errors) Error() string

func (Errors) Errors

func (e Errors) Errors() []Error

func (Errors) String

func (e Errors) String() string

type Parameters

type Parameters struct {
	// contains filtered or unexported fields
}

type Placeholder

type Placeholder map[string]interface{}

This is just a placeholder for the map[string]interface{}, which is used when unmarshalling data from a json object.

type Plan

type Plan map[string]interface{}

Plan is basically the returned Plan type in the response.

func GetDeviceDataPlan

func GetDeviceDataPlan(planid int) Plan

GetDeviceDataPlan returns a given device data plan.

func (Plan) GetDataPlanBillingPeriod

func (plan Plan) GetDataPlanBillingPeriod() float64

GetDataPlanBillingPeriod returns the billing period.

func (Plan) GetDataPlanCarrierId

func (plan Plan) GetDataPlanCarrierId() float64

GetDataPlanCarrierId returns the carrier id of the data plan.

func (Plan) GetDataPlanDescription

func (plan Plan) GetDataPlanDescription() string

GetDataPlanDescription returns the data plan description.

func (Plan) GetDataPlanGroupId

func (plan Plan) GetDataPlanGroupId() float64

GetDataPlanGroupId returns the groupid of the data plan.

func (Plan) GetDataPlanId

func (plan Plan) GetDataPlanId() float64

GetDataPlanId returns the data plan id.

func (Plan) GetDataPlanName

func (plan Plan) GetDataPlanName() string

GetDataPlanName returns the data plan name.

func (Plan) GetDataPlanPartnerId

func (plan Plan) GetDataPlanPartnerId() float64

GetDataPlanPartnerId returns the data plan partner id.

func (Plan) GetDataPlanSize

func (plan Plan) GetDataPlanSize() float64

GetDataPlanSize returns the data size.

func (Plan) GetDataPlanTemplateId

func (plan Plan) GetDataPlanTemplateId() float64

GetDataPlanTemplateId returns the data plan template id.

func (Plan) GetDataPlanTrialDays

func (plan Plan) GetDataPlanTrialDays() float64

GetDataPlanTrialDays returns the number of trial days left.

func (Plan) IsDataPlanEnabled

func (plan Plan) IsDataPlanEnabled() bool

IsDataPlanEnabled returns true if the data plan is enabled.

func (Plan) IsDataPlanRecurring

func (plan Plan) IsDataPlanRecurring() bool

IsDataPlanRecurring returns true if it is recurring.

type Plans

type Plans []interface{}

Plans is just a list of Plan(s).

func GetDeviceDataPlans

func GetDeviceDataPlans() Plans

GetDeviceDataPlans returns device data plans.

type Product

type Product map[string]interface{}

Product implements the Product type returned in the response.

func GetProduct

func GetProduct(id int) Product

GetProduct returns product details response.

func (Product) GetProductDescription

func (product Product) GetProductDescription() string

GetProductDescription returns the description of the product.

func (Product) GetProductId

func (product Product) GetProductId() float64

GetProductId returns the id of the product.

func (Product) GetProductImageUrl

func (product Product) GetProductImageUrl() string

GetProductImageUrl returns the sku of the product.

func (Product) GetProductInvoiceDescription

func (product Product) GetProductInvoiceDescription() string

GetProductInvoiceDescription returns the invoice description of the product.

func (Product) GetProductName

func (product Product) GetProductName() string

GetProductName returns the name of the product.

func (Product) GetProductPreorderDetails

func (product Product) GetProductPreorderDetails() string

GetProductPreorderDetails returns the invoice description of the product.

func (Product) GetProductPrice

func (product Product) GetProductPrice() string

GetProductPrice returns the price of the product.

func (Product) GetProductSku

func (product Product) GetProductSku() string

GetProductSku returns the sku of the product.

type ProductCategories

type ProductCategories []interface{}

func GetProductCategories

func GetProductCategories() ProductCategories

EFFECTS: Returns product categories.

type ProductCategory

type ProductCategory map[string]interface{}

func (ProductCategory) GetProductCategoryName

func (productCategory ProductCategory) GetProductCategoryName() string

func (ProductCategory) GetProductIdsFromCategory

func (productCategory ProductCategory) GetProductIdsFromCategory() []interface{}

EFFECTS: Returns the sku of the product option.

type ProductOption

type ProductOption map[string]interface{}

ProductOption implements the product option returned from the response.

func (ProductOption) GetProductIdFromOption

func (productOption ProductOption) GetProductIdFromOption() float64

GetProductIdFromOption returns the product id.

func (ProductOption) GetProductOptionAppendSku

func (productOption ProductOption) GetProductOptionAppendSku() string

GetProductOptionAppendSku returns the sku of the product option.

func (ProductOption) GetProductOptionDescription

func (productOption ProductOption) GetProductOptionDescription() string

GetProductOptionDescription returns the description of the product option.

func (ProductOption) GetProductOptionInvoiceDescription

func (productOption ProductOption) GetProductOptionInvoiceDescription() string

GetProductOptionInvoiceDescription returns the invoice description of the product option.

func (ProductOption) GetProductOptionPriceChange

func (productOption ProductOption) GetProductOptionPriceChange() string

GetProductOptionPriceChang returns the price change of the product option.

type ProductOptions

type ProductOptions []interface{}

ProductOptions is just a list of ProductOption(s)

func GetProductOptions

func GetProductOptions() ProductOptions

GetProductOptions returns product options.

type Products

type Products []interface{}

Products is just a list of Product(s).

func GetProducts

func GetProducts() Products

GetProducts returns product details.

type Response

type Response http.Response

type ResponseError

type ResponseError struct {
	Body string
	Code int
}

Error returned if there was an issue parsing the response body.

func NewResponseError

func NewResponseError(code int, body string) ResponseError

func (ResponseError) Error

func (e ResponseError) Error() string

type SMS

type SMS map[string]interface{}

SMS implements the SMS type returned from the response.

func SendSMSToDevice

func SendSMSToDevice(deviceid int, phonenumber string) SMS

SendSMSToDevice sends an SMS to a device and returns the response.

type Session

type Session map[string]interface{}

Session implements the Session type returned from the response.

func CreateSession

func CreateSession(email string, password string) Session

CreateSession creates a new session.

func EndSession

func EndSession(sesskey string) Session

EndSession destroys a session based on the given sesskey.

type User

type User map[string]interface{}

User implements the User type returned from the response.

func AddUserAddress

func AddUserAddress() User

AddUserAddress adds a new address to the user.

func ChangeUserPassword

func ChangeUserPassword(password string) User

ChangeUserPassword changes the user's password.

func CreateUser

func CreateUser(id int) User

CreateUser makes a HTTP Post call to create a new user.

func GenerateNewAPIKey

func GenerateNewAPIKey() User

GenerateNewAPIKey generates a new API key.

func GetAPIKey

func GetAPIKey() User

GetAPIKey returns the user's API key.

func GetUserAccountDetails

func GetUserAccountDetails(id int) User

GetUserAccountDetails returns the user's account details based on the given userid.

func GetUserAddresses

func GetUserAddresses() User

GetUserAddresses retrieves user addresses.

func (User) GetUserAPIKey

func (user User) GetUserAPIKey() string

GetUserAPIKey returns the user's API key.

func (User) GetUserFirstName

func (user User) GetUserFirstName() string

GetUserFirstName returns the first name of the given user.

func (User) GetUserLastName

func (user User) GetUserLastName() string

GetUserLastName returns the last name of the given user.

func (User) GetUserRole

func (user User) GetUserRole() string

GetUserRole returns the role of the user.

type Users

type Users []User

Users is just a list of User(s).

Jump to

Keyboard shortcuts

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