forked from codehakase/mobius-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
49 lines (40 loc) · 1.49 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
Package mobius provides methods for interacting with the Mobius Network API.
It automates the HTTP request/response cycle, encodings, and other details needed by the API.
This SDK lets you do everything the API lets you, in a more Go-friendly way.
For further information please see the Official Mobius API documentation at
https://mobius.network/docs/
Original Author: Francis Sunday <twitter.com/codehakase>
QuickStart
package main
import (
"github.com/codehakase/mobius-go"
"fmt"
)
func main() {
mc := mobius.New(yourApiKey, yourAppUID)
// Retrive a struct to communicate with the DApp store
appStore := mc.AppStore
// Get a user's balance
usrBal, err := appStore.Balance("myemail@example.com")
if err != nil {
log.Fatalf("can't fetch user's balance, err: %+v", err)
return
}
fmt.Println("User got %d mobi credits available", usrBal.NumCredits)
// Credit user with mobi credits
if fundUser, err := appStore.Credit("user@example.com", 1000); err != nil {
log.Fatalf("could not fund user, err: %+v", err)
return
}
// Use 20 Mobi Credits from user@example.com
if charge, err := appStore.Use("user@example.com", 20); err == nil {
if charge.Success {
fmt.Printf("User has been charged, and is left with %d mobi credits", charge.NumCredits)
}
} else {
log.Fatalf("could not charge user, err: %+v", err)
}
}
*/
package mobius