mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-24 07:25:35 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
868a78e2e6 | ||
|
|
b771c36d74 | ||
|
|
9fd910f769 |
@@ -35,13 +35,13 @@ type LookupPostcodeResponse struct {
|
||||
|
||||
type Record struct {
|
||||
// building name
|
||||
BuildingName string `json:"building_name"`
|
||||
BuildingName string `json:"buildingName"`
|
||||
// the county
|
||||
County string `json:"county"`
|
||||
// line one of address
|
||||
LineOne string `json:"line_one"`
|
||||
LineOne string `json:"lineOne"`
|
||||
// line two of address
|
||||
LineTwo string `json:"line_two"`
|
||||
LineTwo string `json:"lineTwo"`
|
||||
// dependent locality
|
||||
Locality string `json:"locality"`
|
||||
// organisation if present
|
||||
|
||||
@@ -6,10 +6,6 @@ import (
|
||||
)
|
||||
|
||||
func TestBasicCall(t *testing.T) {
|
||||
if v := os.Getenv("IN_TRAVIS"); v == "yes" {
|
||||
return
|
||||
}
|
||||
|
||||
response := map[string]interface{}{}
|
||||
if err := NewClient(&Options{
|
||||
Token: os.Getenv("TOKEN"),
|
||||
|
||||
@@ -114,13 +114,13 @@ type QuoteRequest struct {
|
||||
|
||||
type QuoteResponse struct {
|
||||
// the asking price
|
||||
AskPrice float64 `json:"ask_price"`
|
||||
AskPrice float64 `json:"askPrice"`
|
||||
// the ask size
|
||||
AskSize float64 `json:"ask_size"`
|
||||
AskSize float64 `json:"askSize"`
|
||||
// the bidding price
|
||||
BidPrice float64 `json:"bid_price"`
|
||||
BidPrice float64 `json:"bidPrice"`
|
||||
// the bid size
|
||||
BidSize float64 `json:"bid_size"`
|
||||
BidSize float64 `json:"bidSize"`
|
||||
// the crypto symbol
|
||||
Symbol string `json:"symbol"`
|
||||
// the UTC timestamp of the quote
|
||||
|
||||
52
db/db.go
52
db/db.go
@@ -40,22 +40,6 @@ func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
}
|
||||
|
||||
// Drop a table in the DB
|
||||
func (t *DbService) DropTable(request *DropTableRequest) (*DropTableResponse, error) {
|
||||
|
||||
rsp := &DropTableResponse{}
|
||||
return rsp, t.client.Call("db", "DropTable", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List tables in the DB
|
||||
func (t *DbService) ListTables(request *ListTablesRequest) (*ListTablesResponse, error) {
|
||||
|
||||
rsp := &ListTablesResponse{}
|
||||
return rsp, t.client.Call("db", "ListTables", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
@@ -64,14 +48,6 @@ func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
}
|
||||
|
||||
// Rename a table
|
||||
func (t *DbService) RenameTable(request *RenameTableRequest) (*RenameTableResponse, error) {
|
||||
|
||||
rsp := &RenameTableResponse{}
|
||||
return rsp, t.client.Call("db", "RenameTable", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Truncate the records in a table
|
||||
func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error) {
|
||||
|
||||
@@ -120,21 +96,6 @@ type DeleteRequest struct {
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type DropTableRequest struct {
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type DropTableResponse struct {
|
||||
}
|
||||
|
||||
type ListTablesRequest struct {
|
||||
}
|
||||
|
||||
type ListTablesResponse struct {
|
||||
// list of tables
|
||||
Tables []string `json:"tables"`
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
// Read by id. Equivalent to 'id == "your-id"'
|
||||
Id string `json:"id"`
|
||||
@@ -161,21 +122,14 @@ type ReadResponse struct {
|
||||
Records []map[string]interface{} `json:"records"`
|
||||
}
|
||||
|
||||
type RenameTableRequest struct {
|
||||
// current table name
|
||||
From string `json:"from"`
|
||||
// new table name
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type RenameTableResponse struct {
|
||||
}
|
||||
|
||||
type TruncateRequest struct {
|
||||
// Optional table name. Defaults to 'default'
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type TruncateResponse struct {
|
||||
// The table truncated
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
|
||||
@@ -28,13 +28,13 @@ type SendRequest struct {
|
||||
// the display name of the sender
|
||||
From string `json:"from"`
|
||||
// the html body
|
||||
HtmlBody string `json:"html_body"`
|
||||
HtmlBody string `json:"htmlBody"`
|
||||
// an optional reply to email address
|
||||
ReplyTo string `json:"reply_to"`
|
||||
ReplyTo string `json:"replyTo"`
|
||||
// the email subject
|
||||
Subject string `json:"subject"`
|
||||
// the text body
|
||||
TextBody string `json:"text_body"`
|
||||
TextBody string `json:"textBody"`
|
||||
// the email address of the recipient
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
@@ -34,50 +34,50 @@ func (t *EvchargersService) Search(request *SearchRequest) (*SearchResponse, err
|
||||
|
||||
type Address struct {
|
||||
// Any comments about how to access the charger
|
||||
AccessComments string `json:"access_comments"`
|
||||
AddressLine1 string `json:"address_line_1"`
|
||||
AddressLine2 string `json:"address_line_2"`
|
||||
AccessComments string `json:"accessComments"`
|
||||
AddressLine1 string `json:"addressLine1"`
|
||||
AddressLine2 string `json:"addressLine2"`
|
||||
Country *Country `json:"country"`
|
||||
CountryId string `json:"country_id"`
|
||||
LatLng string `json:"lat_lng"`
|
||||
CountryId string `json:"countryId"`
|
||||
LatLng string `json:"latLng"`
|
||||
Location *Coordinates `json:"location"`
|
||||
Postcode string `json:"postcode"`
|
||||
StateOrProvince string `json:"state_or_province"`
|
||||
StateOrProvince string `json:"stateOrProvince"`
|
||||
Title string `json:"title"`
|
||||
Town string `json:"town"`
|
||||
}
|
||||
|
||||
type BoundingBox struct {
|
||||
BottomLeft *Coordinates `json:"bottom_left"`
|
||||
TopRight *Coordinates `json:"top_right"`
|
||||
BottomLeft *Coordinates `json:"bottomLeft"`
|
||||
TopRight *Coordinates `json:"topRight"`
|
||||
}
|
||||
|
||||
type ChargerType struct {
|
||||
Comments string `json:"comments"`
|
||||
Id string `json:"id"`
|
||||
// Is this 40KW+
|
||||
IsFastChargeCapable bool `json:"is_fast_charge_capable"`
|
||||
IsFastChargeCapable bool `json:"isFastChargeCapable"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type CheckinStatusType struct {
|
||||
Id string `json:"id"`
|
||||
IsAutomated bool `json:"is_automated"`
|
||||
IsPositive bool `json:"is_positive"`
|
||||
IsAutomated bool `json:"isAutomated"`
|
||||
IsPositive bool `json:"isPositive"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type Connection struct {
|
||||
// The amps offered
|
||||
Amps float64 `json:"amps"`
|
||||
ConnectionType *ConnectionType `json:"connection_type"`
|
||||
ConnectionType *ConnectionType `json:"connectionType"`
|
||||
// The ID of the connection type
|
||||
ConnectionTypeId string `json:"connection_type_id"`
|
||||
ConnectionTypeId string `json:"connectionTypeId"`
|
||||
// The current
|
||||
Current string `json:"current"`
|
||||
Level *ChargerType `json:"level"`
|
||||
// The level of charging power available
|
||||
LevelId string `json:"level_id"`
|
||||
LevelId string `json:"levelId"`
|
||||
// The power in KW
|
||||
Power float64 `json:"power"`
|
||||
Reference string `json:"reference"`
|
||||
@@ -86,10 +86,10 @@ type Connection struct {
|
||||
}
|
||||
|
||||
type ConnectionType struct {
|
||||
FormalName string `json:"formal_name"`
|
||||
FormalName string `json:"formalName"`
|
||||
Id string `json:"id"`
|
||||
IsDiscontinued bool `json:"is_discontinued"`
|
||||
IsObsolete bool `json:"is_obsolete"`
|
||||
IsDiscontinued bool `json:"isDiscontinued"`
|
||||
IsObsolete bool `json:"isObsolete"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ type Coordinates struct {
|
||||
}
|
||||
|
||||
type Country struct {
|
||||
ContinentCode string `json:"continent_code"`
|
||||
ContinentCode string `json:"continentCode"`
|
||||
Id string `json:"id"`
|
||||
IsoCode string `json:"iso_code"`
|
||||
IsoCode string `json:"isoCode"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ type CurrentType struct {
|
||||
|
||||
type DataProvider struct {
|
||||
Comments string `json:"comments"`
|
||||
DataProviderStatusType *DataProviderStatusType `json:"data_provider_status_type"`
|
||||
DataProviderStatusType *DataProviderStatusType `json:"dataProviderStatusType"`
|
||||
Id string `json:"id"`
|
||||
// How is this data licensed
|
||||
License string `json:"license"`
|
||||
@@ -123,19 +123,19 @@ type DataProvider struct {
|
||||
|
||||
type DataProviderStatusType struct {
|
||||
Id string `json:"id"`
|
||||
IsProviderEnabled bool `json:"is_provider_enabled"`
|
||||
IsProviderEnabled bool `json:"isProviderEnabled"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type Operator struct {
|
||||
Comments string `json:"comments"`
|
||||
ContactEmail string `json:"contact_email"`
|
||||
FaultReportEmail string `json:"fault_report_email"`
|
||||
ContactEmail string `json:"contactEmail"`
|
||||
FaultReportEmail string `json:"faultReportEmail"`
|
||||
Id string `json:"id"`
|
||||
// Is this operator a private individual vs a company
|
||||
IsPrivateIndividual bool `json:"is_private_individual"`
|
||||
PhonePrimary string `json:"phone_primary"`
|
||||
PhoneSecondary string `json:"phone_secondary"`
|
||||
IsPrivateIndividual bool `json:"isPrivateIndividual"`
|
||||
PhonePrimary string `json:"phonePrimary"`
|
||||
PhoneSecondary string `json:"phoneSecondary"`
|
||||
Title string `json:"title"`
|
||||
Website string `json:"website"`
|
||||
}
|
||||
@@ -148,19 +148,19 @@ type Poi struct {
|
||||
// The cost of charging
|
||||
Cost string `json:"cost"`
|
||||
// The ID of the data provider
|
||||
DataProviderId string `json:"data_provider_id"`
|
||||
DataProviderId string `json:"dataProviderId"`
|
||||
// The ID of the charger
|
||||
Id string `json:"id"`
|
||||
// The number of charging points
|
||||
NumPoints int64 `json:"num_points,string"`
|
||||
NumPoints int64 `json:"numPoints,string"`
|
||||
// The operator
|
||||
Operator *Operator `json:"operator"`
|
||||
// The ID of the operator of the charger
|
||||
OperatorId string `json:"operator_id"`
|
||||
OperatorId string `json:"operatorId"`
|
||||
// The type of usage
|
||||
UsageType *UsageType `json:"usage_type"`
|
||||
UsageType *UsageType `json:"usageType"`
|
||||
// The type of usage for this charger point (is it public, membership required, etc)
|
||||
UsageTypeId string `json:"usage_type_id"`
|
||||
UsageTypeId string `json:"usageTypeId"`
|
||||
}
|
||||
|
||||
type ReferenceDataRequest struct {
|
||||
@@ -168,36 +168,36 @@ type ReferenceDataRequest struct {
|
||||
|
||||
type ReferenceDataResponse struct {
|
||||
// The types of charger
|
||||
ChargerTypes *ChargerType `json:"charger_types"`
|
||||
ChargerTypes *ChargerType `json:"chargerTypes"`
|
||||
// The types of checkin status
|
||||
CheckinStatusTypes *CheckinStatusType `json:"checkin_status_types"`
|
||||
CheckinStatusTypes *CheckinStatusType `json:"checkinStatusTypes"`
|
||||
// The types of connection
|
||||
ConnectionTypes *ConnectionType `json:"connection_types"`
|
||||
ConnectionTypes *ConnectionType `json:"connectionTypes"`
|
||||
// The countries
|
||||
Countries []Country `json:"countries"`
|
||||
// The types of current
|
||||
CurrentTypes *CurrentType `json:"current_types"`
|
||||
CurrentTypes *CurrentType `json:"currentTypes"`
|
||||
// The providers of the charger data
|
||||
DataProviders *DataProvider `json:"data_providers"`
|
||||
DataProviders *DataProvider `json:"dataProviders"`
|
||||
// The companies operating the chargers
|
||||
Operators []Operator `json:"operators"`
|
||||
// The status of the charger
|
||||
StatusTypes *StatusType `json:"status_types"`
|
||||
StatusTypes *StatusType `json:"statusTypes"`
|
||||
// The status of a submission
|
||||
SubmissionStatusTypes *SubmissionStatusType `json:"submission_status_types"`
|
||||
SubmissionStatusTypes *SubmissionStatusType `json:"submissionStatusTypes"`
|
||||
// The different types of usage
|
||||
UsageTypes *UsageType `json:"usage_types"`
|
||||
UsageTypes *UsageType `json:"usageTypes"`
|
||||
// The types of user comment
|
||||
UserCommentTypes *UserCommentType `json:"user_comment_types"`
|
||||
UserCommentTypes *UserCommentType `json:"userCommentTypes"`
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
// Bounding box to search within (top left and bottom right coordinates)
|
||||
Box *BoundingBox `json:"box"`
|
||||
// IDs of the connection type
|
||||
ConnectionTypes string `json:"connection_types"`
|
||||
ConnectionTypes string `json:"connectionTypes"`
|
||||
// Country ID
|
||||
CountryId string `json:"country_id"`
|
||||
CountryId string `json:"countryId"`
|
||||
// Search distance from point in metres, defaults to 5000m
|
||||
Distance int64 `json:"distance,string"`
|
||||
// Supported charging levels
|
||||
@@ -205,13 +205,13 @@ type SearchRequest struct {
|
||||
// Coordinates from which to begin search
|
||||
Location *Coordinates `json:"location"`
|
||||
// Maximum number of results to return, defaults to 100
|
||||
MaxResults int64 `json:"max_results,string"`
|
||||
MaxResults int64 `json:"maxResults,string"`
|
||||
// Minimum power in KW. Note: data not available for many chargers
|
||||
MinPower int64 `json:"min_power,string"`
|
||||
MinPower int64 `json:"minPower,string"`
|
||||
// IDs of the the EV charger operator
|
||||
Operators []string `json:"operators"`
|
||||
// Usage of the charge point (is it public, membership required, etc)
|
||||
UsageTypes string `json:"usage_types"`
|
||||
UsageTypes string `json:"usageTypes"`
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
@@ -220,21 +220,21 @@ type SearchResponse struct {
|
||||
|
||||
type StatusType struct {
|
||||
Id string `json:"id"`
|
||||
IsOperational bool `json:"is_operational"`
|
||||
IsOperational bool `json:"isOperational"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type SubmissionStatusType struct {
|
||||
Id string `json:"id"`
|
||||
IsLive bool `json:"is_live"`
|
||||
IsLive bool `json:"isLive"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type UsageType struct {
|
||||
Id string `json:"id"`
|
||||
IsAccessKeyRequired bool `json:"is_access_key_required"`
|
||||
IsMembershipRequired bool `json:"is_membership_required"`
|
||||
IsPayAtLocation bool `json:"is_pay_at_location"`
|
||||
IsAccessKeyRequired bool `json:"isAccessKeyRequired"`
|
||||
IsMembershipRequired bool `json:"isMembershipRequired"`
|
||||
IsPayAtLocation bool `json:"isPayAtLocation"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
|
||||
114
examples/cache/README.md
vendored
114
examples/cache/README.md
vendored
@@ -4,63 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Set
|
||||
|
||||
Set an item in the cache. Overwrites any existing value already set.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Set an item in the cache. Overwrites any existing value already set.
|
||||
func SetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Set(&cache.SetRequest{
|
||||
Key: "foo",
|
||||
Value: "bar",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Get
|
||||
|
||||
Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||
func GetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||
Key: "foo",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a value from the cache. If key not found a success response is returned.
|
||||
@@ -147,3 +90,60 @@ Value: 2,
|
||||
|
||||
}
|
||||
```
|
||||
## Set
|
||||
|
||||
Set an item in the cache. Overwrites any existing value already set.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Set an item in the cache. Overwrites any existing value already set.
|
||||
func SetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Set(&cache.SetRequest{
|
||||
Key: "foo",
|
||||
Value: "bar",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Get
|
||||
|
||||
Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||
func GetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||
Key: "foo",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Quote
|
||||
|
||||
Get the last quote for a given crypto ticker
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Get the last quote for a given crypto ticker
|
||||
func GetAcryptocurrencyQuote() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.Quote(&crypto.QuoteRequest{
|
||||
Symbol: "BTCUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Returns the history for the previous close
|
||||
@@ -116,3 +88,31 @@ func GetCryptocurrencyPrice() {
|
||||
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
|
||||
Get the last quote for a given crypto ticker
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Get the last quote for a given crypto ticker
|
||||
func GetAcryptocurrencyQuote() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.Quote(&crypto.QuoteRequest{
|
||||
Symbol: "BTCUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,40 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Create
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
},
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a record in the database. Include an "id" in the record to update.
|
||||
@@ -34,69 +68,6 @@ Table: "users",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## RenameTable
|
||||
|
||||
Rename a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Rename a table
|
||||
func RenameTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
||||
From: "events",
|
||||
To: "events_backup",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
},
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
@@ -183,34 +154,6 @@ func TruncateTable() {
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## DropTable
|
||||
|
||||
Drop a table in the DB
|
||||
|
||||
|
||||
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Drop a table in the DB
|
||||
func DropTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Count
|
||||
@@ -241,30 +184,3 @@ func CountEntriesInAtable() {
|
||||
|
||||
}
|
||||
```
|
||||
## ListTables
|
||||
|
||||
List tables in the DB
|
||||
|
||||
|
||||
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// List tables in the DB
|
||||
func ListTables() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Drop a table in the DB
|
||||
func main() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
||||
Table: "users",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// List tables in the DB
|
||||
func main() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.ListTables(&db.ListTablesRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Rename a table
|
||||
func main() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
||||
From: "events",
|
||||
To: "events_backup",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
@@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Find
|
||||
|
||||
Find an emoji by its alias e.g :beer:
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Find an emoji by its alias e.g :beer:
|
||||
func FindEmoji() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Find(&emoji.FindRequest{
|
||||
Alias: ":beer:",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Flag
|
||||
|
||||
Get the flag for a country. Requires country code e.g GB for great britain
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Get the flag for a country. Requires country code e.g GB for great britain
|
||||
func GetFlagByCountryCode() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Flag(&emoji.FlagRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Print
|
||||
|
||||
Print text and renders the emojis with aliases e.g
|
||||
@@ -64,58 +119,3 @@ To: "+44782669123",
|
||||
|
||||
}
|
||||
```
|
||||
## Find
|
||||
|
||||
Find an emoji by its alias e.g :beer:
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Find an emoji by its alias e.g :beer:
|
||||
func FindEmoji() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Find(&emoji.FindRequest{
|
||||
Alias: ":beer:",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Flag
|
||||
|
||||
Get the flag for a country. Requires country code e.g GB for great britain
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Get the flag for a country. Requires country code e.g GB for great britain
|
||||
func GetFlagByCountryCode() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Flag(&emoji.FlagRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Evchargers/api
|
||||
|
||||
Endpoints:
|
||||
|
||||
## ReferenceData
|
||||
|
||||
Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||
|
||||
|
||||
[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/evchargers"
|
||||
)
|
||||
|
||||
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||
func GetReferenceData() {
|
||||
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Search
|
||||
|
||||
Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||
@@ -98,30 +125,3 @@ Location: &evchargers.Coordinates{
|
||||
|
||||
}
|
||||
```
|
||||
## ReferenceData
|
||||
|
||||
Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||
|
||||
|
||||
[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/evchargers"
|
||||
)
|
||||
|
||||
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||
func GetReferenceData() {
|
||||
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -26,9 +26,9 @@ func PublishAnEvent() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ func main() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
})
|
||||
|
||||
17
examples/event/subscribe/subscribeToATopic.go
Executable file
17
examples/event/subscribe/subscribeToATopic.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func SubscribeToAtopic() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Subscribe(&event.SubscribeRequest{
|
||||
Topic: "user",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Read
|
||||
|
||||
Read a file by path
|
||||
|
||||
|
||||
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/file"
|
||||
)
|
||||
|
||||
// Read a file by path
|
||||
func ReadFile() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.Read(&file.ReadRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Save
|
||||
|
||||
Save a file
|
||||
@@ -93,32 +122,3 @@ Project: "examples",
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read a file by path
|
||||
|
||||
|
||||
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/file"
|
||||
)
|
||||
|
||||
// Read a file by path
|
||||
func ReadFile() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.Read(&file.ReadRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## History
|
||||
|
||||
Returns the data for the previous close
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Returns the data for the previous close
|
||||
func GetPreviousClose() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.History(&forex.HistoryRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Price
|
||||
|
||||
Get the latest price for a given forex ticker
|
||||
@@ -88,3 +60,31 @@ func GetAfxQuote() {
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Returns the data for the previous close
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Returns the data for the previous close
|
||||
func GetPreviousClose() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.History(&forex.HistoryRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,206 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Resize
|
||||
|
||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
If one of width or height is 0, the image aspect ratio is preserved.
|
||||
Optional cropping.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
func Base64toHostedImage() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||
Height: 100,
|
||||
Name: "cat.png",
|
||||
Width: 100,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Resize
|
||||
|
||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
If one of width or height is 0, the image aspect ratio is preserved.
|
||||
Optional cropping.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
func Base64toBase64image() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||
Height: 100,
|
||||
Width: 100,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Resize
|
||||
|
||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
If one of width or height is 0, the image aspect ratio is preserved.
|
||||
Optional cropping.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
func Base64toBase64imageWithCropping() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||
CropOptions: &image.CropOptions{
|
||||
Height: 50,
|
||||
Width: 50,
|
||||
},
|
||||
Height: 100,
|
||||
Width: 100,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Convert
|
||||
|
||||
Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
||||
or by uploading the conversion result.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Convert](https://m3o.com/image/api#Convert)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
||||
// or by uploading the conversion result.
|
||||
func ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Convert(&image.ConvertRequest{
|
||||
Name: "cat.jpeg",
|
||||
Url: "somewebsite.com/cat.png",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
To resize an image before uploading, see the Resize endpoint.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
// To resize an image before uploading, see the Resize endpoint.
|
||||
func UploadAbase64imageToMicrosCdn() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Upload(&image.UploadRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
|
||||
Name: "cat.jpeg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
To resize an image before uploading, see the Resize endpoint.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
// To resize an image before uploading, see the Resize endpoint.
|
||||
func UploadAnImageFromAurlToMicrosCdn() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Upload(&image.UploadRequest{
|
||||
Name: "cat.jpeg",
|
||||
Url: "somewebsite.com/cat.png",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an image previously uploaded.
|
||||
@@ -32,227 +232,3 @@ func DeleteAnUploadedImage() {
|
||||
|
||||
}
|
||||
```
|
||||
## Resize
|
||||
|
||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
If one of width or height is 0, the image aspect ratio is preserved.
|
||||
Optional cropping.
|
||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
with each parameter as a form field.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func Base64toHostedImage() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||
Height: 100,
|
||||
Name: "cat.png",
|
||||
Width: 100,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Resize
|
||||
|
||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
If one of width or height is 0, the image aspect ratio is preserved.
|
||||
Optional cropping.
|
||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
with each parameter as a form field.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func Base64toBase64image() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||
Height: 100,
|
||||
Width: 100,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Resize
|
||||
|
||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
If one of width or height is 0, the image aspect ratio is preserved.
|
||||
Optional cropping.
|
||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
with each parameter as a form field.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func Base64toBase64imageWithCropping() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||
CropOptions: &image.CropOptions{
|
||||
Height: 50,
|
||||
Width: 50,
|
||||
},
|
||||
Height: 100,
|
||||
Width: 100,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Convert
|
||||
|
||||
Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
||||
or by uploading the conversion result.
|
||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
with each parameter as a form field.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Convert](https://m3o.com/image/api#Convert)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
||||
// or by uploading the conversion result.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Convert(&image.ConvertRequest{
|
||||
Name: "cat.jpeg",
|
||||
Url: "somewebsite.com/cat.png",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
To resize an image before uploading, see the Resize endpoint.
|
||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
with each parameter as a form field.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
// To resize an image before uploading, see the Resize endpoint.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func UploadAbase64imageToMicrosCdn() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Upload(&image.UploadRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
|
||||
Name: "cat.jpeg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
To resize an image before uploading, see the Resize endpoint.
|
||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
with each parameter as a form field.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
// To resize an image before uploading, see the Resize endpoint.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func UploadAnImageFromAurlToMicrosCdn() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Upload(&image.UploadRequest{
|
||||
Name: "cat.jpeg",
|
||||
Url: "somewebsite.com/cat.png",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -9,8 +9,6 @@ import (
|
||||
|
||||
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
||||
// or by uploading the conversion result.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func main() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Convert(&image.ConvertRequest{
|
||||
|
||||
@@ -10,8 +10,6 @@ import (
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func main() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
|
||||
@@ -10,8 +10,6 @@ import (
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func main() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
|
||||
@@ -10,8 +10,6 @@ import (
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func main() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
|
||||
@@ -9,8 +9,6 @@ import (
|
||||
|
||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
// To resize an image before uploading, see the Resize endpoint.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func main() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Upload(&image.UploadRequest{
|
||||
|
||||
@@ -9,8 +9,6 @@ import (
|
||||
|
||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
// To resize an image before uploading, see the Resize endpoint.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func main() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Upload(&image.UploadRequest{
|
||||
|
||||
17
examples/notes/subscribe/subscribeToEvents.go
Executable file
17
examples/notes/subscribe/subscribeToEvents.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Specify the note to events
|
||||
func SubscribeToEvents() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Subscribe(¬es.SubscribeRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
# Spam
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Spam/api](https://m3o.com/Spam/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Classify
|
||||
|
||||
Check whether an email is likely to be spam based on its attributes
|
||||
|
||||
|
||||
[https://m3o.com/spam/api#Classify](https://m3o.com/spam/api#Classify)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/spam"
|
||||
)
|
||||
|
||||
// Check whether an email is likely to be spam based on its attributes
|
||||
func ClassifyAnEmail() {
|
||||
spamService := spam.NewSpamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spamService.Classify(&spam.ClassifyRequest{
|
||||
From: "noreply@m3o.com",
|
||||
Subject: "Welcome",
|
||||
To: "hello@example.com",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Classify
|
||||
|
||||
Check whether an email is likely to be spam based on its attributes
|
||||
|
||||
|
||||
[https://m3o.com/spam/api#Classify](https://m3o.com/spam/api#Classify)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/spam"
|
||||
)
|
||||
|
||||
// Check whether an email is likely to be spam based on its attributes
|
||||
func ClassifyAnEmailUsingTheRawData() {
|
||||
spamService := spam.NewSpamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spamService.Classify(&spam.ClassifyRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
@@ -1,20 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/spam"
|
||||
)
|
||||
|
||||
// Check whether an email is likely to be spam based on its attributes
|
||||
func main() {
|
||||
spamService := spam.NewSpamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spamService.Classify(&spam.ClassifyRequest{
|
||||
From: "noreply@m3o.com",
|
||||
Subject: "Welcome",
|
||||
To: "hello@example.com",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/spam"
|
||||
)
|
||||
|
||||
// Check whether an email is likely to be spam based on its attributes
|
||||
func main() {
|
||||
spamService := spam.NewSpamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spamService.Classify(&spam.ClassifyRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stock/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Price
|
||||
|
||||
Get the last price for a given stock ticker
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the last price for a given stock ticker
|
||||
func GetAstockPrice() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.Price(&stock.PriceRequest{
|
||||
Symbol: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
|
||||
Get the last quote for the stock
|
||||
@@ -121,3 +93,31 @@ Stock: "AAPL",
|
||||
|
||||
}
|
||||
```
|
||||
## Price
|
||||
|
||||
Get the last price for a given stock ticker
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the last price for a given stock ticker
|
||||
func GetAstockPrice() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.Price(&stock.PriceRequest{
|
||||
Symbol: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,63 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## SendMessage
|
||||
|
||||
Send a message to the stream.
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#SendMessage](https://m3o.com/stream/api#SendMessage)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Send a message to the stream.
|
||||
func SendMessage() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.SendMessage(&stream.SendMessageRequest{
|
||||
Channel: "general",
|
||||
Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ListMessages
|
||||
|
||||
List messages for a given channel
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// List messages for a given channel
|
||||
func ListMessages() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
|
||||
Channel: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ListChannels
|
||||
|
||||
List all the active channels
|
||||
@@ -62,60 +119,3 @@ Name: "general",
|
||||
|
||||
}
|
||||
```
|
||||
## SendMessage
|
||||
|
||||
Send a message to the stream.
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#SendMessage](https://m3o.com/stream/api#SendMessage)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Send a message to the stream.
|
||||
func SendMessage() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.SendMessage(&stream.SendMessageRequest{
|
||||
Channel: "general",
|
||||
Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ListMessages
|
||||
|
||||
List messages for a given channel
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// List messages for a given channel
|
||||
func ListMessages() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
|
||||
Channel: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
22
examples/stream/publish/publishAMessage.go
Executable file
22
examples/stream/publish/publishAMessage.go
Executable file
@@ -0,0 +1,22 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Publish a message to the stream. Specify a topic to group messages for a specific topic.
|
||||
func PublishAmessage() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.Publish(&stream.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "events",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
22
examples/stream/publish/publishAMessage/main.go
Executable file
22
examples/stream/publish/publishAMessage/main.go
Executable file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Publish a message to the stream. Specify a topic to group messages for a specific topic.
|
||||
func main() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.Publish(&stream.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "events",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/stream/subscribe/subscribeToATopic.go
Executable file
17
examples/stream/subscribe/subscribeToATopic.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func SubscribeToAtopic() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.Subscribe(&stream.SubscribeRequest{
|
||||
Topic: "events",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/stream/subscribe/subscribeToATopic/main.go
Executable file
17
examples/stream/subscribe/subscribeToATopic/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func main() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.Subscribe(&stream.SubscribeRequest{
|
||||
Topic: "events",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sunnah/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Collections
|
||||
|
||||
Get a list of available collections. A collection is
|
||||
a compilation of hadiths collected and written by an author.
|
||||
|
||||
|
||||
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/sunnah"
|
||||
)
|
||||
|
||||
// Get a list of available collections. A collection is
|
||||
// a compilation of hadiths collected and written by an author.
|
||||
func ListAvailableCollections() {
|
||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Books
|
||||
|
||||
Get a list of books from within a collection. A book can contain many chapters
|
||||
@@ -94,32 +123,3 @@ Collection: "bukhari",
|
||||
|
||||
}
|
||||
```
|
||||
## Collections
|
||||
|
||||
Get a list of available collections. A collection is
|
||||
a compilation of hadiths collected and written by an author.
|
||||
|
||||
|
||||
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/sunnah"
|
||||
)
|
||||
|
||||
// Get a list of available collections. A collection is
|
||||
// a compilation of hadiths collected and written by an author.
|
||||
func ListAvailableCollections() {
|
||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -26,7 +26,7 @@ func TakeScreenshotOfAurl() {
|
||||
thumbnailService := thumbnail.NewThumbnailService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := thumbnailService.Screenshot(&thumbnail.ScreenshotRequest{
|
||||
Height: 600,
|
||||
Url: "https://google.com",
|
||||
Url: "https://m3o.com",
|
||||
Width: 600,
|
||||
|
||||
})
|
||||
|
||||
@@ -12,7 +12,7 @@ func main() {
|
||||
thumbnailService := thumbnail.NewThumbnailService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := thumbnailService.Screenshot(&thumbnail.ScreenshotRequest{
|
||||
Height: 600,
|
||||
Url: "https://google.com",
|
||||
Url: "https://m3o.com",
|
||||
Width: 600,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
@@ -4,6 +4,37 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Login
|
||||
|
||||
Login using username or email. The response will return a new session for successful login,
|
||||
401 in the case of login failure and 500 for any other error
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Login using username or email. The response will return a new session for successful login,
|
||||
// 401 in the case of login failure and 500 for any other error
|
||||
func LogAuserIn() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Login(&user.LoginRequest{
|
||||
Email: "joe@example.com",
|
||||
Password: "mySecretPass123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Logout
|
||||
|
||||
Logout a user account
|
||||
@@ -25,66 +56,7 @@ import(
|
||||
func LogAuserOut() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Logout(&user.LogoutRequest{
|
||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ReadSession
|
||||
|
||||
Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||
func ReadAsessionByTheSessionId() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
|
||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a new user account. The email address and username for the account must be unique.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Create a new user account. The email address and username for the account must be unique.
|
||||
func CreateAnAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Create(&user.CreateRequest{
|
||||
Email: "joe@example.com",
|
||||
Id: "user-1",
|
||||
Password: "Password1",
|
||||
Username: "joe",
|
||||
SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -112,143 +84,8 @@ import(
|
||||
func UpdateAnAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Update(&user.UpdateRequest{
|
||||
Email: "joe+2@example.com",
|
||||
Id: "user-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## SendVerificationEmail
|
||||
|
||||
Send a verification email
|
||||
to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com',
|
||||
but you can provide the title and contents.
|
||||
The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
The variable will be replaced with an actual url that will look similar to this:
|
||||
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Send a verification email
|
||||
// to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com',
|
||||
// but you can provide the title and contents.
|
||||
// The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
// The variable will be replaced with an actual url that will look similar to this:
|
||||
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
func SendVerificationEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
FailureRedirectUrl: "https://m3o.com/verification-failed",
|
||||
FromName: "Awesome Dot Com",
|
||||
RedirectUrl: "https://m3o.com",
|
||||
Subject: "Email verification",
|
||||
TextContent: `Hi there,
|
||||
|
||||
Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ResetPassword
|
||||
|
||||
Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
func ResetPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
||||
Code: "012345",
|
||||
ConfirmPassword: "NewPassword1",
|
||||
Email: "joe@example.com",
|
||||
NewPassword: "NewPassword1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an account by id
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Delete an account by id
|
||||
func DeleteUserAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Delete(&user.DeleteRequest{
|
||||
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all users. Returns a paged list of results
|
||||
|
||||
|
||||
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// List all users. Returns a paged list of results
|
||||
func ListAllUsers() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.List(&user.ListRequest{
|
||||
Limit: 100,
|
||||
Offset: 0,
|
||||
Email: "joeotheremail@example.com",
|
||||
Id: "usrid-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -276,9 +113,9 @@ import(
|
||||
func UpdateTheAccountPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "Password2",
|
||||
NewPassword: "Password2",
|
||||
OldPassword: "Password1",
|
||||
ConfirmPassword: "myEvenMoreSecretPass123",
|
||||
NewPassword: "myEvenMoreSecretPass123",
|
||||
OldPassword: "mySecretPass123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -306,7 +143,7 @@ import(
|
||||
func ReadAnAccountById() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Read(&user.ReadRequest{
|
||||
Id: "user-1",
|
||||
Id: "usrid-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -334,7 +171,7 @@ import(
|
||||
func ReadAccountByUsernameOrEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Read(&user.ReadRequest{
|
||||
Username: "joe",
|
||||
Username: "usrname-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -369,13 +206,18 @@ func ReadAccountByEmail() {
|
||||
|
||||
}
|
||||
```
|
||||
## SendPasswordResetEmail
|
||||
## SendVerificationEmail
|
||||
|
||||
Send an email with a verification code to reset password.
|
||||
Call "ResetPassword" endpoint once user provides the code.
|
||||
Send a verification email
|
||||
to the user being signed up. Email from will be from 'support@m3o.com',
|
||||
but you can provide the title and contents.
|
||||
The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
The variable will be replaced with an actual url that will look similar to this:
|
||||
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
||||
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -387,16 +229,83 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Send an email with a verification code to reset password.
|
||||
// Call "ResetPassword" endpoint once user provides the code.
|
||||
func SendPasswordResetEmail() {
|
||||
// Send a verification email
|
||||
// to the user being signed up. Email from will be from 'support@m3o.com',
|
||||
// but you can provide the title and contents.
|
||||
// The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
// The variable will be replaced with an actual url that will look similar to this:
|
||||
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
func SendVerificationEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
|
||||
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
FailureRedirectUrl: "https://m3o.com/verification-failed",
|
||||
FromName: "Awesome Dot Com",
|
||||
Subject: "Password reset",
|
||||
RedirectUrl: "https://m3o.com",
|
||||
Subject: "Email verification",
|
||||
TextContent: `Hi there,
|
||||
click here to reset your password: myapp.com/reset/code?=$code`,
|
||||
|
||||
Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an account by id
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Delete an account by id
|
||||
func DeleteUserAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Delete(&user.DeleteRequest{
|
||||
Id: "fdf34f34f34-f34f34-f43f43f34-f4f34f",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a new user account. The email address and username for the account must be unique.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Create a new user account. The email address and username for the account must be unique.
|
||||
func CreateAnAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Create(&user.CreateRequest{
|
||||
Email: "joe@example.com",
|
||||
Id: "usrid-1",
|
||||
Password: "mySecretPass123",
|
||||
Username: "usrname-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -424,21 +333,19 @@ import(
|
||||
func VerifyEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
Token: "012345",
|
||||
Token: "t2323t232t",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Login
|
||||
## ReadSession
|
||||
|
||||
Login using username or email. The response will return a new session for successful login,
|
||||
401 in the case of login failure and 500 for any other error
|
||||
Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
||||
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -450,13 +357,11 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Login using username or email. The response will return a new session for successful login,
|
||||
// 401 in the case of login failure and 500 for any other error
|
||||
func LogAuserIn() {
|
||||
// Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||
func ReadAsessionByTheSessionId() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Login(&user.LoginRequest{
|
||||
Email: "joe@example.com",
|
||||
Password: "Password1",
|
||||
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
|
||||
SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
@@ -12,9 +12,9 @@ func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Create(&user.CreateRequest{
|
||||
Email: "joe@example.com",
|
||||
Id: "user-1",
|
||||
Password: "Password1",
|
||||
Username: "joe",
|
||||
Id: "usrid-1",
|
||||
Password: "mySecretPass123",
|
||||
Username: "usrname-1",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Delete(&user.DeleteRequest{
|
||||
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
|
||||
Id: "fdf34f34f34-f34f34-f43f43f34-f4f34f",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// List all users. Returns a paged list of results
|
||||
func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.List(&user.ListRequest{
|
||||
Limit: 100,
|
||||
Offset: 0,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
@@ -13,7 +13,7 @@ func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Login(&user.LoginRequest{
|
||||
Email: "joe@example.com",
|
||||
Password: "Password1",
|
||||
Password: "mySecretPass123",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Logout(&user.LogoutRequest{
|
||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||
SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Read(&user.ReadRequest{
|
||||
Username: "joe",
|
||||
Username: "usrname-1",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Read(&user.ReadRequest{
|
||||
Id: "user-1",
|
||||
Id: "usrid-1",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
|
||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||
SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
||||
Code: "012345",
|
||||
ConfirmPassword: "NewPassword1",
|
||||
Email: "joe@example.com",
|
||||
NewPassword: "NewPassword1",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Send an email with a verification code to reset password.
|
||||
// Call "ResetPassword" endpoint once user provides the code.
|
||||
func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
FromName: "Awesome Dot Com",
|
||||
Subject: "Password reset",
|
||||
TextContent: `Hi there,
|
||||
click here to reset your password: myapp.com/reset/code?=$code`,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// Send a verification email
|
||||
// to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com',
|
||||
// to the user being signed up. Email from will be from 'support@m3o.com',
|
||||
// but you can provide the title and contents.
|
||||
// The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Update(&user.UpdateRequest{
|
||||
Email: "joe+2@example.com",
|
||||
Id: "user-1",
|
||||
Email: "joeotheremail@example.com",
|
||||
Id: "usrid-1",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "Password2",
|
||||
NewPassword: "Password2",
|
||||
OldPassword: "Password1",
|
||||
ConfirmPassword: "myEvenMoreSecretPass123",
|
||||
NewPassword: "myEvenMoreSecretPass123",
|
||||
OldPassword: "mySecretPass123",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
|
||||
@@ -11,8 +11,7 @@ import (
|
||||
func main() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
Token: "012345",
|
||||
Token: "t2323t232t",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
|
||||
@@ -81,9 +81,9 @@ type QuoteRequest struct {
|
||||
|
||||
type QuoteResponse struct {
|
||||
// the asking price
|
||||
AskPrice float64 `json:"ask_price"`
|
||||
AskPrice float64 `json:"askPrice"`
|
||||
// the bidding price
|
||||
BidPrice float64 `json:"bid_price"`
|
||||
BidPrice float64 `json:"bidPrice"`
|
||||
// the forex symbol
|
||||
Symbol string `json:"symbol"`
|
||||
// the UTC timestamp of the quote
|
||||
|
||||
@@ -83,7 +83,7 @@ type DeployRequest struct {
|
||||
// if not provided, defaults to the name parameter
|
||||
Entrypoint string `json:"entrypoint"`
|
||||
// environment variables to pass in at runtime
|
||||
EnvVars map[string]string `json:"env_vars"`
|
||||
EnvVars map[string]string `json:"envVars"`
|
||||
// function name
|
||||
Name string `json:"name"`
|
||||
// project is used for namespacing your functions
|
||||
@@ -120,7 +120,7 @@ type DescribeResponse struct {
|
||||
// The timeout for requests to the function
|
||||
Timeout string `json:"timeout"`
|
||||
// The time at which the function was updated
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type Func struct {
|
||||
|
||||
@@ -35,8 +35,8 @@ func (t *GeocodingService) Reverse(request *ReverseRequest) (*ReverseResponse, e
|
||||
type Address struct {
|
||||
City string `json:"city"`
|
||||
Country string `json:"country"`
|
||||
LineOne string `json:"line_one"`
|
||||
LineTwo string `json:"line_two"`
|
||||
LineOne string `json:"lineOne"`
|
||||
LineTwo string `json:"lineTwo"`
|
||||
Postcode string `json:"postcode"`
|
||||
}
|
||||
|
||||
|
||||
46
gifs/gifs.go
46
gifs/gifs.go
@@ -26,7 +26,7 @@ func (t *GifsService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||
|
||||
type Gif struct {
|
||||
// URL used for embedding the GIF
|
||||
EmbedUrl string `json:"embed_url"`
|
||||
EmbedUrl string `json:"embedUrl"`
|
||||
// The ID of the GIF
|
||||
Id string `json:"id"`
|
||||
// The different formats available for this GIF
|
||||
@@ -34,7 +34,7 @@ type Gif struct {
|
||||
// The content rating for the GIF
|
||||
Rating string `json:"rating"`
|
||||
// A short URL for this GIF
|
||||
ShortUrl string `json:"short_url"`
|
||||
ShortUrl string `json:"shortUrl"`
|
||||
// The slug used in the GIF's URL
|
||||
Slug string `json:"slug"`
|
||||
// The page on which this GIF was found
|
||||
@@ -49,17 +49,17 @@ type ImageFormat struct {
|
||||
// height
|
||||
Height int32 `json:"height"`
|
||||
// size of the MP4 version
|
||||
Mp4Size int32 `json:"mp4_size"`
|
||||
Mp4size int32 `json:"mp4size"`
|
||||
// URL to an MP4 version of the gif
|
||||
Mp4Url string `json:"mp4_url"`
|
||||
Mp4url string `json:"mp4url"`
|
||||
// size in bytes
|
||||
Size int32 `json:"size"`
|
||||
// URL of the gif
|
||||
Url string `json:"url"`
|
||||
// size of the webp version
|
||||
WebpSize int32 `json:"webp_size"`
|
||||
WebpSize int32 `json:"webpSize"`
|
||||
// URL to a webp version of the gif
|
||||
WebpUrl string `json:"webp_url"`
|
||||
WebpUrl string `json:"webpUrl"`
|
||||
// width
|
||||
Width int32 `json:"width"`
|
||||
}
|
||||
@@ -68,43 +68,43 @@ type ImageFormats struct {
|
||||
// A downsized version of the GIF < 2MB
|
||||
Downsized *ImageFormat `json:"downsized"`
|
||||
// A downsized version of the GIF < 8MB
|
||||
DownsizedLarge *ImageFormat `json:"downsized_large"`
|
||||
DownsizedLarge *ImageFormat `json:"downsizedLarge"`
|
||||
// A downsized version of the GIF < 5MB
|
||||
DownsizedMedium *ImageFormat `json:"downsized_medium"`
|
||||
DownsizedMedium *ImageFormat `json:"downsizedMedium"`
|
||||
// A downsized version of the GIF < 200kb
|
||||
DownsizedSmall *ImageFormat `json:"downsized_small"`
|
||||
DownsizedSmall *ImageFormat `json:"downsizedSmall"`
|
||||
// Static image of the downsized version of the GIF
|
||||
DownsizedStill *ImageFormat `json:"downsized_still"`
|
||||
DownsizedStill *ImageFormat `json:"downsizedStill"`
|
||||
// Version of the GIF with fixed height of 200 pixels. Good for mobile use
|
||||
FixedHeight *ImageFormat `json:"fixed_height"`
|
||||
FixedHeight *ImageFormat `json:"fixedHeight"`
|
||||
// Version of the GIF with fixed height of 200 pixels and number of frames reduced to 6
|
||||
FixedHeightDownsampled *ImageFormat `json:"fixed_height_downsampled"`
|
||||
FixedHeightDownsampled *ImageFormat `json:"fixedHeightDownsampled"`
|
||||
// Version of the GIF with fixed height of 100 pixels. Good for mobile keyboards
|
||||
FixedHeightSmall *ImageFormat `json:"fixed_height_small"`
|
||||
FixedHeightSmall *ImageFormat `json:"fixedHeightSmall"`
|
||||
// Static image of the GIF with fixed height of 100 pixels
|
||||
FixedHeightSmallStill *ImageFormat `json:"fixed_height_small_still"`
|
||||
FixedHeightSmallStill *ImageFormat `json:"fixedHeightSmallStill"`
|
||||
// Static image of the GIF with fixed height of 200 pixels
|
||||
FixedHeightStill *ImageFormat `json:"fixed_height_still"`
|
||||
FixedHeightStill *ImageFormat `json:"fixedHeightStill"`
|
||||
// Version of the GIF with fixed width of 200 pixels. Good for mobile use
|
||||
FixedWidth *ImageFormat `json:"fixed_width"`
|
||||
FixedWidth *ImageFormat `json:"fixedWidth"`
|
||||
// Version of the GIF with fixed width of 200 pixels and number of frames reduced to 6
|
||||
FixedWidthDownsampled *ImageFormat `json:"fixed_width_downsampled"`
|
||||
FixedWidthDownsampled *ImageFormat `json:"fixedWidthDownsampled"`
|
||||
// Version of the GIF with fixed width of 100 pixels. Good for mobile keyboards
|
||||
FixedWidthSmall *ImageFormat `json:"fixed_width_small"`
|
||||
FixedWidthSmall *ImageFormat `json:"fixedWidthSmall"`
|
||||
// Static image of the GIF with fixed width of 100 pixels
|
||||
FixedWidthSmallStill *ImageFormat `json:"fixed_width_small_still"`
|
||||
FixedWidthSmallStill *ImageFormat `json:"fixedWidthSmallStill"`
|
||||
// Static image of the GIF with fixed width of 200 pixels
|
||||
FixedWidthStill *ImageFormat `json:"fixed_width_still"`
|
||||
FixedWidthStill *ImageFormat `json:"fixedWidthStill"`
|
||||
// 15 second version of the GIF looping
|
||||
Looping *ImageFormat `json:"looping"`
|
||||
// The original GIF. Good for desktop use
|
||||
Original *ImageFormat `json:"original"`
|
||||
// Static image of the original version of the GIF
|
||||
OriginalStill *ImageFormat `json:"original_still"`
|
||||
OriginalStill *ImageFormat `json:"originalStill"`
|
||||
// mp4 version of the GIF <50kb displaying first 1-2 secs
|
||||
Preview *ImageFormat `json:"preview"`
|
||||
// Version of the GIF <50kb displaying first 1-2 secs
|
||||
PreviewGif *ImageFormat `json:"preview_gif"`
|
||||
PreviewGif *ImageFormat `json:"previewGif"`
|
||||
}
|
||||
|
||||
type Pagination struct {
|
||||
@@ -113,7 +113,7 @@ type Pagination struct {
|
||||
// position in pagination
|
||||
Offset int32 `json:"offset"`
|
||||
// total number of results available
|
||||
TotalCount int32 `json:"total_count"`
|
||||
TotalCount int32 `json:"totalCount"`
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
|
||||
@@ -36,7 +36,7 @@ type SearchResponse struct {
|
||||
|
||||
type SearchResult struct {
|
||||
// abridged version of this search result’s URL, e.g. www.exampe.com
|
||||
DisplayUrl string `json:"display_url"`
|
||||
DisplayUrl string `json:"displayUrl"`
|
||||
// id of the result
|
||||
Id string `json:"id"`
|
||||
// kind of result; "search"
|
||||
|
||||
@@ -48,11 +48,11 @@ type Country struct {
|
||||
|
||||
type Holiday struct {
|
||||
// the country this holiday occurs in
|
||||
CountryCode string `json:"country_code"`
|
||||
CountryCode string `json:"countryCode"`
|
||||
// date of the holiday in yyyy-mm-dd format
|
||||
Date string `json:"date"`
|
||||
// the local name of the holiday
|
||||
LocalName string `json:"local_name"`
|
||||
LocalName string `json:"localName"`
|
||||
// the name of the holiday in English
|
||||
Name string `json:"name"`
|
||||
// the regions within the country that observe this holiday (if not all of them)
|
||||
@@ -63,7 +63,7 @@ type Holiday struct {
|
||||
|
||||
type ListRequest struct {
|
||||
// The 2 letter country code (as defined in ISO 3166-1 alpha-2)
|
||||
CountryCode string `json:"country_code"`
|
||||
CountryCode string `json:"countryCode"`
|
||||
// The year to list holidays for
|
||||
Year int64 `json:"year,string"`
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ type ImageService struct {
|
||||
|
||||
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
||||
// or by uploading the conversion result.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func (t *ImageService) Convert(request *ConvertRequest) (*ConvertResponse, error) {
|
||||
|
||||
rsp := &ConvertResponse{}
|
||||
@@ -38,8 +36,6 @@ func (t *ImageService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func (t *ImageService) Resize(request *ResizeRequest) (*ResizeResponse, error) {
|
||||
|
||||
rsp := &ResizeResponse{}
|
||||
@@ -49,8 +45,6 @@ func (t *ImageService) Resize(request *ResizeRequest) (*ResizeResponse, error) {
|
||||
|
||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
// To resize an image before uploading, see the Resize endpoint.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func (t *ImageService) Upload(request *UploadRequest) (*UploadResponse, error) {
|
||||
|
||||
rsp := &UploadResponse{}
|
||||
@@ -61,12 +55,10 @@ func (t *ImageService) Upload(request *UploadRequest) (*UploadResponse, error) {
|
||||
type ConvertRequest struct {
|
||||
// base64 encoded image to resize,
|
||||
Base64 string `json:"base64"`
|
||||
// The image file to convert
|
||||
File string `json:"file"`
|
||||
// output name of the image including extension, ie. "cat.png"
|
||||
Name string `json:"name"`
|
||||
// make output a URL and not a base64 response
|
||||
OutputUrl bool `json:"outputURL"`
|
||||
OutputUrl bool `json:"outputUrl"`
|
||||
// url of the image to resize
|
||||
Url string `json:"url"`
|
||||
}
|
||||
@@ -113,13 +105,11 @@ type ResizeRequest struct {
|
||||
// if provided, after resize, the image
|
||||
// will be cropped
|
||||
CropOptions *CropOptions `json:"cropOptions"`
|
||||
// The image file to resize
|
||||
File string `json:"file"`
|
||||
Height int64 `json:"height,string"`
|
||||
// output name of the image including extension, ie. "cat.png"
|
||||
Name string `json:"name"`
|
||||
// make output a URL and not a base64 response
|
||||
OutputUrl bool `json:"outputURL"`
|
||||
OutputUrl bool `json:"outputUrl"`
|
||||
// url of the image to resize
|
||||
Url string `json:"url"`
|
||||
Width int64 `json:"width,string"`
|
||||
@@ -133,8 +123,6 @@ type ResizeResponse struct {
|
||||
type UploadRequest struct {
|
||||
// Base64 encoded image to upload,
|
||||
Base64 string `json:"base64"`
|
||||
// The image file to upload
|
||||
File string `json:"file"`
|
||||
// Output name of the image including extension, ie. "cat.png"
|
||||
Name string `json:"name"`
|
||||
// URL of the image to upload
|
||||
|
||||
3
m3o.go
3
m3o.go
@@ -34,7 +34,6 @@ import (
|
||||
"go.m3o.com/rss"
|
||||
"go.m3o.com/sentiment"
|
||||
"go.m3o.com/sms"
|
||||
"go.m3o.com/spam"
|
||||
"go.m3o.com/stock"
|
||||
"go.m3o.com/stream"
|
||||
"go.m3o.com/sunnah"
|
||||
@@ -85,7 +84,6 @@ func NewClient(token string) *Client {
|
||||
RssService: rss.NewRssService(token),
|
||||
SentimentService: sentiment.NewSentimentService(token),
|
||||
SmsService: sms.NewSmsService(token),
|
||||
SpamService: spam.NewSpamService(token),
|
||||
StockService: stock.NewStockService(token),
|
||||
StreamService: stream.NewStreamService(token),
|
||||
SunnahService: sunnah.NewSunnahService(token),
|
||||
@@ -136,7 +134,6 @@ type Client struct {
|
||||
RssService *rss.RssService
|
||||
SentimentService *sentiment.SentimentService
|
||||
SmsService *sms.SmsService
|
||||
SpamService *spam.SpamService
|
||||
StockService *stock.StockService
|
||||
StreamService *stream.StreamService
|
||||
SunnahService *sunnah.SunnahService
|
||||
|
||||
@@ -52,9 +52,9 @@ func (t *QuranService) Verses(request *VersesRequest) (*VersesResponse, error) {
|
||||
|
||||
type Chapter struct {
|
||||
// The arabic name of the chapter
|
||||
ArabicName string `json:"arabic_name"`
|
||||
ArabicName string `json:"arabicName"`
|
||||
// The complex name of the chapter
|
||||
ComplexName string `json:"complex_name"`
|
||||
ComplexName string `json:"complexName"`
|
||||
// The id of the chapter as a number e.g 1
|
||||
Id int32 `json:"id"`
|
||||
// The simple name of the chapter
|
||||
@@ -62,13 +62,13 @@ type Chapter struct {
|
||||
// The pages from and to e.g 1, 1
|
||||
Pages []int32 `json:"pages"`
|
||||
// Should the chapter start with bismillah
|
||||
PrefixBismillah bool `json:"prefix_bismillah"`
|
||||
PrefixBismillah bool `json:"prefixBismillah"`
|
||||
// The order in which it was revealed
|
||||
RevelationOrder int32 `json:"revelation_order"`
|
||||
RevelationOrder int32 `json:"revelationOrder"`
|
||||
// The place of revelation
|
||||
RevelationPlace string `json:"revelation_place"`
|
||||
RevelationPlace string `json:"revelationPlace"`
|
||||
// The translated name
|
||||
TranslatedName string `json:"translated_name"`
|
||||
TranslatedName string `json:"translatedName"`
|
||||
// The number of verses in the chapter
|
||||
Verses int32 `json:"verses"`
|
||||
}
|
||||
@@ -97,9 +97,9 @@ type Result struct {
|
||||
// The related translations to the text
|
||||
Translations []Translation `json:"translations"`
|
||||
// The unique verse id across the Quran
|
||||
VerseId int32 `json:"verse_id"`
|
||||
VerseId int32 `json:"verseId"`
|
||||
// The verse key e.g 1:1
|
||||
VerseKey string `json:"verse_key"`
|
||||
VerseKey string `json:"verseKey"`
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
@@ -121,9 +121,9 @@ type SearchResponse struct {
|
||||
// The results for the query
|
||||
Results []Result `json:"results"`
|
||||
// The total pages
|
||||
TotalPages int32 `json:"total_pages"`
|
||||
TotalPages int32 `json:"totalPages"`
|
||||
// The total results returned
|
||||
TotalResults int32 `json:"total_results"`
|
||||
TotalResults int32 `json:"totalResults"`
|
||||
}
|
||||
|
||||
type SummaryRequest struct {
|
||||
@@ -167,7 +167,7 @@ type Verse struct {
|
||||
// The arabic text for this verse
|
||||
Text string `json:"text"`
|
||||
// The basic translation of the verse
|
||||
TranslatedText string `json:"translated_text"`
|
||||
TranslatedText string `json:"translatedText"`
|
||||
// The alternative translations for the verse
|
||||
Translations []Translation `json:"translations"`
|
||||
// The phonetic transliteration from arabic
|
||||
@@ -199,14 +199,14 @@ type VersesResponse struct {
|
||||
// The page requested
|
||||
Page int32 `json:"page"`
|
||||
// The total pages
|
||||
TotalPages int32 `json:"total_pages"`
|
||||
TotalPages int32 `json:"totalPages"`
|
||||
// The verses on the page
|
||||
Verses []Verse `json:"verses"`
|
||||
}
|
||||
|
||||
type Word struct {
|
||||
// The character type e.g word, end
|
||||
CharType string `json:"char_type"`
|
||||
CharType string `json:"charType"`
|
||||
// The QCF v2 font code
|
||||
Code string `json:"code"`
|
||||
// The id of the word within the verse
|
||||
|
||||
@@ -98,8 +98,8 @@ type Intersection struct {
|
||||
|
||||
type Maneuver struct {
|
||||
Action string `json:"action"`
|
||||
BearingAfter float64 `json:"bearing_after"`
|
||||
BearingBefore float64 `json:"bearing_before"`
|
||||
BearingAfter float64 `json:"bearingAfter"`
|
||||
BearingBefore float64 `json:"bearingBefore"`
|
||||
Direction string `json:"direction"`
|
||||
Location *Point `json:"location"`
|
||||
}
|
||||
|
||||
49
spam/spam.go
49
spam/spam.go
@@ -1,49 +0,0 @@
|
||||
package spam
|
||||
|
||||
import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
func NewSpamService(token string) *SpamService {
|
||||
return &SpamService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type SpamService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Check whether an email is likely to be spam based on its attributes
|
||||
func (t *SpamService) Classify(request *ClassifyRequest) (*ClassifyResponse, error) {
|
||||
|
||||
rsp := &ClassifyResponse{}
|
||||
return rsp, t.client.Call("spam", "Classify", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type ClassifyRequest struct {
|
||||
// The raw body of the email including headers etc per RFC 822. Alternatively, use the other parameters to correctly format the message
|
||||
EmailBody string `json:"email_body"`
|
||||
// The email address it has been sent from
|
||||
From string `json:"from"`
|
||||
// the HTML version of the email body
|
||||
HtmlBody string `json:"html_body"`
|
||||
// The subject of the email
|
||||
Subject string `json:"subject"`
|
||||
// the plain text version of the email body
|
||||
TextBody string `json:"text_body"`
|
||||
// The email address it is being sent to
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type ClassifyResponse struct {
|
||||
// The rules that have contributed to this score
|
||||
Details []string `json:"details"`
|
||||
// Is it spam? Returns true if its score is > 5
|
||||
IsSpam bool `json:"is_spam"`
|
||||
// The score evaluated for this email. A higher number means it is more likely to be spam
|
||||
Score float64 `json:"score"`
|
||||
}
|
||||
@@ -74,13 +74,13 @@ type HistoryResponse struct {
|
||||
|
||||
type Order struct {
|
||||
// the asking price
|
||||
AskPrice float64 `json:"ask_price"`
|
||||
AskPrice float64 `json:"askPrice"`
|
||||
// the ask size
|
||||
AskSize int32 `json:"ask_size"`
|
||||
AskSize int32 `json:"askSize"`
|
||||
// the bidding price
|
||||
BidPrice float64 `json:"bid_price"`
|
||||
BidPrice float64 `json:"bidPrice"`
|
||||
// the bid size
|
||||
BidSize int32 `json:"bid_size"`
|
||||
BidSize int32 `json:"bidSize"`
|
||||
// the UTC timestamp of the quote
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
@@ -126,13 +126,13 @@ type QuoteRequest struct {
|
||||
|
||||
type QuoteResponse struct {
|
||||
// the asking price
|
||||
AskPrice float64 `json:"ask_price"`
|
||||
AskPrice float64 `json:"askPrice"`
|
||||
// the ask size
|
||||
AskSize int32 `json:"ask_size"`
|
||||
AskSize int32 `json:"askSize"`
|
||||
// the bidding price
|
||||
BidPrice float64 `json:"bid_price"`
|
||||
BidPrice float64 `json:"bidPrice"`
|
||||
// the bid size
|
||||
BidSize int32 `json:"bid_size"`
|
||||
BidSize int32 `json:"bidSize"`
|
||||
// the stock symbol
|
||||
Symbol string `json:"symbol"`
|
||||
// the UTC timestamp of the quote
|
||||
|
||||
@@ -53,7 +53,7 @@ type Channel struct {
|
||||
// description for the channel
|
||||
Description string `json:"description"`
|
||||
// last activity time
|
||||
LastActive string `json:"last_active"`
|
||||
LastActive string `json:"lastActive"`
|
||||
// name of the channel
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func (t *SunnahService) Hadiths(request *HadithsRequest) (*HadithsResponse, erro
|
||||
|
||||
type Book struct {
|
||||
// arabic name of the book
|
||||
ArabicName string `json:"arabic_name"`
|
||||
ArabicName string `json:"arabicName"`
|
||||
// number of hadiths in the book
|
||||
Hadiths int32 `json:"hadiths"`
|
||||
// number of the book e.g 1
|
||||
@@ -86,7 +86,7 @@ type BooksResponse struct {
|
||||
|
||||
type Chapter struct {
|
||||
// arabic title
|
||||
ArabicTitle string `json:"arabic_title"`
|
||||
ArabicTitle string `json:"arabicTitle"`
|
||||
// the book number
|
||||
Book int32 `json:"book"`
|
||||
// the chapter id e.g 1
|
||||
@@ -125,7 +125,7 @@ type ChaptersResponse struct {
|
||||
|
||||
type Collection struct {
|
||||
// Arabic title if available
|
||||
ArabicTitle string `json:"arabic_title"`
|
||||
ArabicTitle string `json:"arabicTitle"`
|
||||
// Total hadiths in the collection
|
||||
Hadiths int32 `json:"hadiths"`
|
||||
// Name of the collection e.g bukhari
|
||||
@@ -149,15 +149,15 @@ type CollectionsResponse struct {
|
||||
|
||||
type Hadith struct {
|
||||
// the arabic chapter title
|
||||
ArabicChapterTitle string `json:"arabic_chapter_title"`
|
||||
ArabicChapterTitle string `json:"arabicChapterTitle"`
|
||||
// the arabic text
|
||||
ArabicText string `json:"arabic_text"`
|
||||
ArabicText string `json:"arabicText"`
|
||||
// the chapter id
|
||||
Chapter int32 `json:"chapter"`
|
||||
// the chapter key
|
||||
ChapterKey string `json:"chapter_key"`
|
||||
ChapterKey string `json:"chapterKey"`
|
||||
// the chapter title
|
||||
ChapterTitle string `json:"chapter_title"`
|
||||
ChapterTitle string `json:"chapterTitle"`
|
||||
// hadith id
|
||||
Id int32 `json:"id"`
|
||||
// hadith text
|
||||
|
||||
@@ -33,5 +33,5 @@ type ScreenshotRequest struct {
|
||||
}
|
||||
|
||||
type ScreenshotResponse struct {
|
||||
ImageUrl string `json:"imageURL"`
|
||||
ImageUrl string `json:"imageUrl"`
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func (t *TwitterService) User(request *UserRequest) (*UserResponse, error) {
|
||||
|
||||
type Profile struct {
|
||||
// the account creation date
|
||||
CreatedAt string `json:"created_at"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
// the user description
|
||||
Description string `json:"description"`
|
||||
// the follower count
|
||||
@@ -58,7 +58,7 @@ type Profile struct {
|
||||
// the user id
|
||||
Id int64 `json:"id,string"`
|
||||
// The user's profile picture
|
||||
ImageUrl string `json:"image_url"`
|
||||
ImageUrl string `json:"imageUrl"`
|
||||
// the user's location
|
||||
Location string `json:"location"`
|
||||
// display name of the user
|
||||
@@ -99,7 +99,7 @@ type Trend struct {
|
||||
// name of the trend
|
||||
Name string `json:"name"`
|
||||
// the volume of tweets in last 24 hours
|
||||
TweetVolume int64 `json:"tweet_volume,string"`
|
||||
TweetVolume int64 `json:"tweetVolume,string"`
|
||||
// the twitter url
|
||||
Url string `json:"url"`
|
||||
}
|
||||
@@ -114,13 +114,13 @@ type TrendsResponse struct {
|
||||
|
||||
type Tweet struct {
|
||||
// time of tweet
|
||||
CreatedAt string `json:"created_at"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
// number of times favourited
|
||||
FavouritedCount int64 `json:"favourited_count,string"`
|
||||
FavouritedCount int64 `json:"favouritedCount,string"`
|
||||
// id of the tweet
|
||||
Id int64 `json:"id,string"`
|
||||
// number of times retweeted
|
||||
RetweetedCount int64 `json:"retweeted_count,string"`
|
||||
RetweetedCount int64 `json:"retweetedCount,string"`
|
||||
// text of the tweet
|
||||
Text string `json:"text"`
|
||||
// username of the person who tweeted
|
||||
|
||||
14
url/url.go
14
url/url.go
@@ -42,7 +42,7 @@ func (t *UrlService) Shorten(request *ShortenRequest) (*ShortenResponse, error)
|
||||
|
||||
type ListRequest struct {
|
||||
// filter by short URL, optional
|
||||
ShortUrl string `json:"shortURL"`
|
||||
ShortUrl string `json:"shortUrl"`
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
@@ -52,28 +52,28 @@ type ListResponse struct {
|
||||
type ProxyRequest struct {
|
||||
// short url ID, without the domain, eg. if your short URL is
|
||||
// `m3o.one/u/someshorturlid` then pass in `someshorturlid`
|
||||
ShortUrl string `json:"shortURL"`
|
||||
ShortUrl string `json:"shortUrl"`
|
||||
}
|
||||
|
||||
type ProxyResponse struct {
|
||||
DestinationUrl string `json:"destinationURL"`
|
||||
DestinationUrl string `json:"destinationUrl"`
|
||||
}
|
||||
|
||||
type ShortenRequest struct {
|
||||
DestinationUrl string `json:"destinationURL"`
|
||||
DestinationUrl string `json:"destinationUrl"`
|
||||
}
|
||||
|
||||
type ShortenResponse struct {
|
||||
ShortUrl string `json:"shortURL"`
|
||||
ShortUrl string `json:"shortUrl"`
|
||||
}
|
||||
|
||||
type URLPair struct {
|
||||
Created int64 `json:"created,string"`
|
||||
DestinationUrl string `json:"destinationURL"`
|
||||
DestinationUrl string `json:"destinationUrl"`
|
||||
// HitCount keeps track many times the short URL has been resolved.
|
||||
// Hitcount only gets saved to disk (database) after every 10th hit, so
|
||||
// its not intended to be 100% accurate, more like an almost correct estimate.
|
||||
HitCount int64 `json:"hitCount,string"`
|
||||
Owner string `json:"owner"`
|
||||
ShortUrl string `json:"shortURL"`
|
||||
ShortUrl string `json:"shortUrl"`
|
||||
}
|
||||
|
||||
77
user/user.go
77
user/user.go
@@ -32,14 +32,6 @@ func (t *UserService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
}
|
||||
|
||||
// List all users. Returns a paged list of results
|
||||
func (t *UserService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("user", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Login using username or email. The response will return a new session for successful login,
|
||||
// 401 in the case of login failure and 500 for any other error
|
||||
func (t *UserService) Login(request *LoginRequest) (*LoginResponse, error) {
|
||||
@@ -73,25 +65,8 @@ func (t *UserService) ReadSession(request *ReadSessionRequest) (*ReadSessionResp
|
||||
|
||||
}
|
||||
|
||||
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
func (t *UserService) ResetPassword(request *ResetPasswordRequest) (*ResetPasswordResponse, error) {
|
||||
|
||||
rsp := &ResetPasswordResponse{}
|
||||
return rsp, t.client.Call("user", "ResetPassword", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Send an email with a verification code to reset password.
|
||||
// Call "ResetPassword" endpoint once user provides the code.
|
||||
func (t *UserService) SendPasswordResetEmail(request *SendPasswordResetEmailRequest) (*SendPasswordResetEmailResponse, error) {
|
||||
|
||||
rsp := &SendPasswordResetEmailResponse{}
|
||||
return rsp, t.client.Call("user", "SendPasswordResetEmail", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Send a verification email
|
||||
// to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com',
|
||||
// to the user being signed up. Email from will be from 'support@m3o.com',
|
||||
// but you can provide the title and contents.
|
||||
// The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
@@ -172,17 +147,6 @@ type DeleteRequest struct {
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// Maximum number of records to return. Default limit is 25.
|
||||
// Maximum limit is 1000. Anything higher will return an error.
|
||||
Limit int32 `json:"limit"`
|
||||
Offset int32 `json:"offset"`
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
Users []Account `json:"users"`
|
||||
}
|
||||
|
||||
type LoginRequest struct {
|
||||
// The email address of the user
|
||||
Email string `json:"email"`
|
||||
@@ -198,7 +162,6 @@ type LoginResponse struct {
|
||||
}
|
||||
|
||||
type LogoutRequest struct {
|
||||
// the session id for the user to logout
|
||||
SessionId string `json:"sessionId"`
|
||||
}
|
||||
|
||||
@@ -224,47 +187,15 @@ type ReadSessionRequest struct {
|
||||
}
|
||||
|
||||
type ReadSessionResponse struct {
|
||||
// the session for the user
|
||||
Session *Session `json:"session"`
|
||||
}
|
||||
|
||||
type ResetPasswordRequest struct {
|
||||
// The code from the verification email
|
||||
Code string `json:"code"`
|
||||
// confirm new password
|
||||
ConfirmPassword string `json:"confirmPassword"`
|
||||
// the email to reset the password for
|
||||
Email string `json:"email"`
|
||||
// the new password
|
||||
NewPassword string `json:"newPassword"`
|
||||
}
|
||||
|
||||
type ResetPasswordResponse struct {
|
||||
}
|
||||
|
||||
type SendPasswordResetEmailRequest struct {
|
||||
// email address to send reset for
|
||||
Email string `json:"email"`
|
||||
// Display name of the sender for the email. Note: the email address will still be 'noreply@email.m3ocontent.com'
|
||||
FromName string `json:"fromName"`
|
||||
// subject of the email
|
||||
Subject string `json:"subject"`
|
||||
// Text content of the email. Don't forget to include the string '$code' which will be replaced by the real verification link
|
||||
// HTML emails are not available currently.
|
||||
TextContent string `json:"textContent"`
|
||||
}
|
||||
|
||||
type SendPasswordResetEmailResponse struct {
|
||||
}
|
||||
|
||||
type SendVerificationEmailRequest struct {
|
||||
// email address to send the verification code
|
||||
Email string `json:"email"`
|
||||
FailureRedirectUrl string `json:"failureRedirectUrl"`
|
||||
// Display name of the sender for the email. Note: the email address will still be 'noreply@email.m3ocontent.com'
|
||||
// Display name of the sender for the email. Note: the email address will still be 'support@m3o.com'
|
||||
FromName string `json:"fromName"`
|
||||
RedirectUrl string `json:"redirectUrl"`
|
||||
// subject of the email
|
||||
Subject string `json:"subject"`
|
||||
// Text content of the email. Don't forget to include the string '$micro_verification_link' which will be replaced by the real verification link
|
||||
// HTML emails are not available currently.
|
||||
@@ -287,7 +218,7 @@ type Session struct {
|
||||
|
||||
type UpdatePasswordRequest struct {
|
||||
// confirm new password
|
||||
ConfirmPassword string `json:"confirm_password"`
|
||||
ConfirmPassword string `json:"confirmPassword"`
|
||||
// the new password
|
||||
NewPassword string `json:"newPassword"`
|
||||
// the old password
|
||||
@@ -314,8 +245,6 @@ type UpdateResponse struct {
|
||||
}
|
||||
|
||||
type VerifyEmailRequest struct {
|
||||
// the email address to verify
|
||||
Email string `json:"email"`
|
||||
// The token from the verification email
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
@@ -31,33 +31,33 @@ type LookupRequest struct {
|
||||
|
||||
type LookupResponse struct {
|
||||
// co2 emmissions
|
||||
Co2Emissions float64 `json:"co2_emissions"`
|
||||
Co2emissions float64 `json:"co2emissions"`
|
||||
// colour of vehicle
|
||||
Colour string `json:"colour"`
|
||||
// engine capacity
|
||||
EngineCapacity int32 `json:"engine_capacity"`
|
||||
EngineCapacity int32 `json:"engineCapacity"`
|
||||
// fuel type e.g petrol, diesel
|
||||
FuelType string `json:"fuel_type"`
|
||||
FuelType string `json:"fuelType"`
|
||||
// date of last v5 issue
|
||||
LastV5Issued string `json:"last_v5_issued"`
|
||||
LastV5issued string `json:"lastV5issued"`
|
||||
// make of vehicle
|
||||
Make string `json:"make"`
|
||||
// month of first registration
|
||||
MonthOfFirstRegistration string `json:"month_of_first_registration"`
|
||||
MonthOfFirstRegistration string `json:"monthOfFirstRegistration"`
|
||||
// mot expiry
|
||||
MotExpiry string `json:"mot_expiry"`
|
||||
MotExpiry string `json:"motExpiry"`
|
||||
// mot status
|
||||
MotStatus string `json:"mot_status"`
|
||||
MotStatus string `json:"motStatus"`
|
||||
// registration number
|
||||
Registration string `json:"registration"`
|
||||
// tax due data
|
||||
TaxDueDate string `json:"tax_due_date"`
|
||||
TaxDueDate string `json:"taxDueDate"`
|
||||
// tax status
|
||||
TaxStatus string `json:"tax_status"`
|
||||
TaxStatus string `json:"taxStatus"`
|
||||
// type approvale
|
||||
TypeApproval string `json:"type_approval"`
|
||||
TypeApproval string `json:"typeApproval"`
|
||||
// wheel plan
|
||||
Wheelplan string `json:"wheelplan"`
|
||||
// year of manufacture
|
||||
YearOfManufacture int32 `json:"year_of_manufacture"`
|
||||
YearOfManufacture int32 `json:"yearOfManufacture"`
|
||||
}
|
||||
|
||||
@@ -34,31 +34,31 @@ func (t *WeatherService) Now(request *NowRequest) (*NowResponse, error) {
|
||||
|
||||
type Forecast struct {
|
||||
// the average temp in celsius
|
||||
AvgTempC float64 `json:"avg_temp_c"`
|
||||
AvgTempC float64 `json:"avgTempC"`
|
||||
// the average temp in fahrenheit
|
||||
AvgTempF float64 `json:"avg_temp_f"`
|
||||
AvgTempF float64 `json:"avgTempF"`
|
||||
// chance of rain (percentage)
|
||||
ChanceOfRain int32 `json:"chance_of_rain"`
|
||||
ChanceOfRain int32 `json:"chanceOfRain"`
|
||||
// forecast condition
|
||||
Condition string `json:"condition"`
|
||||
// date of the forecast
|
||||
Date string `json:"date"`
|
||||
// the URL of forecast condition icon. Simply prefix with either http or https to use it
|
||||
IconUrl string `json:"icon_url"`
|
||||
IconUrl string `json:"iconUrl"`
|
||||
// max temp in celsius
|
||||
MaxTempC float64 `json:"max_temp_c"`
|
||||
MaxTempC float64 `json:"maxTempC"`
|
||||
// max temp in fahrenheit
|
||||
MaxTempF float64 `json:"max_temp_f"`
|
||||
MaxTempF float64 `json:"maxTempF"`
|
||||
// minimum temp in celsius
|
||||
MinTempC float64 `json:"min_temp_c"`
|
||||
MinTempC float64 `json:"minTempC"`
|
||||
// minimum temp in fahrenheit
|
||||
MinTempF float64 `json:"min_temp_f"`
|
||||
MinTempF float64 `json:"minTempF"`
|
||||
// time of sunrise
|
||||
Sunrise string `json:"sunrise"`
|
||||
// time of sunset
|
||||
Sunset string `json:"sunset"`
|
||||
// will it rain
|
||||
WillItRain bool `json:"will_it_rain"`
|
||||
WillItRain bool `json:"willItRain"`
|
||||
}
|
||||
|
||||
type ForecastRequest struct {
|
||||
@@ -76,7 +76,7 @@ type ForecastResponse struct {
|
||||
// e.g 37.55
|
||||
Latitude float64 `json:"latitude"`
|
||||
// the local time
|
||||
LocalTime string `json:"local_time"`
|
||||
LocalTime string `json:"localTime"`
|
||||
// location of the request
|
||||
Location string `json:"location"`
|
||||
// e.g -77.46
|
||||
@@ -102,17 +102,17 @@ type NowResponse struct {
|
||||
// whether its daytime
|
||||
Daytime bool `json:"daytime"`
|
||||
// feels like in celsius
|
||||
FeelsLikeC float64 `json:"feels_like_c"`
|
||||
FeelsLikeC float64 `json:"feelsLikeC"`
|
||||
// feels like in fahrenheit
|
||||
FeelsLikeF float64 `json:"feels_like_f"`
|
||||
FeelsLikeF float64 `json:"feelsLikeF"`
|
||||
// the humidity percentage
|
||||
Humidity int32 `json:"humidity"`
|
||||
// the URL of the related icon. Simply prefix with either http or https to use it
|
||||
IconUrl string `json:"icon_url"`
|
||||
IconUrl string `json:"iconUrl"`
|
||||
// e.g 37.55
|
||||
Latitude float64 `json:"latitude"`
|
||||
// the local time
|
||||
LocalTime string `json:"local_time"`
|
||||
LocalTime string `json:"localTime"`
|
||||
// location of the request
|
||||
Location string `json:"location"`
|
||||
// e.g -77.46
|
||||
@@ -120,17 +120,17 @@ type NowResponse struct {
|
||||
// region related to the location
|
||||
Region string `json:"region"`
|
||||
// temperature in celsius
|
||||
TempC float64 `json:"temp_c"`
|
||||
TempC float64 `json:"tempC"`
|
||||
// temperature in fahrenheit
|
||||
TempF float64 `json:"temp_f"`
|
||||
TempF float64 `json:"tempF"`
|
||||
// timezone of the location
|
||||
Timezone string `json:"timezone"`
|
||||
// wind degree
|
||||
WindDegree int32 `json:"wind_degree"`
|
||||
WindDegree int32 `json:"windDegree"`
|
||||
// wind direction
|
||||
WindDirection string `json:"wind_direction"`
|
||||
WindDirection string `json:"windDirection"`
|
||||
// wind in kph
|
||||
WindKph float64 `json:"wind_kph"`
|
||||
WindKph float64 `json:"windKph"`
|
||||
// wind in mph
|
||||
WindMph float64 `json:"wind_mph"`
|
||||
WindMph float64 `json:"windMph"`
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ type SearchResult struct {
|
||||
// none, upcoming, live, completed
|
||||
Broadcasting string `json:"broadcasting"`
|
||||
// the channel id
|
||||
ChannelId string `json:"channel_id"`
|
||||
ChannelId string `json:"channelId"`
|
||||
// the channel title
|
||||
ChannelTitle string `json:"channel_title"`
|
||||
ChannelTitle string `json:"channelTitle"`
|
||||
// the result description
|
||||
Description string `json:"description"`
|
||||
// id of the result
|
||||
@@ -49,7 +49,7 @@ type SearchResult struct {
|
||||
// kind of result; "video", "channel", "playlist"
|
||||
Kind string `json:"kind"`
|
||||
// published at time
|
||||
PublishedAt string `json:"published_at"`
|
||||
PublishedAt string `json:"publishedAt"`
|
||||
// title of the result
|
||||
Title string `json:"title"`
|
||||
// the associated url
|
||||
|
||||
Reference in New Issue
Block a user