ovoid

package module
v0.0.0-...-631cc27 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

Un-Official Ovoid API Wrapper package for Go

Documentation Test-master Actions Status Go Report Card Ask Me Anything ! made-with-Go

Repository berikut ini merupakan porting dari ovoid untuk Go

Install

go get github.com/adibaulia/ovoid-go

Usage

Anda harus mendapatkan Token untuk menggunakan API Ovo.

Langkah 1

package main

import (
  ovo "github.com/adibaulia/ovoid-go"
)

func main(){
  login, err := ovo.NewOvoLogin("your_phone")
  if err != nil {
    ...
  }

  l, err := login.Login2FA()
  if err != nil {
    ...
  }

Langkah 2

  accessToken, err := login.Login2FAVerify(l.RefID, "your_verification_code")
  if err != nil {
    ...
  }

Langkah 3

  auth, err := login.LoginSecurityCode(accessToken.UpdateAccessToken)
  if err != nil {
      ...
  }
  YOUR_TOKEN := auth.Token

Lalu gunakan YOUR_TOKEN untuk menggunakan package ovoid. Contoh:

package main

import (
  ovo "github.com/adibaulia/ovoid-go"
)

func main(){
  o, err := ovo.NewClient("YOUR_TOKEN")
  if err != nil {
    ...
  }

  b, err := o.GetAllBalance()
  if err != nil {
    ...
  }
}

Progress

Masih dalam pengembangan. Silahkan Pull Request untuk berkontribusi.

Thank You !

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	Mobile            string `json:"mobile,omitempty"`
	Email             string `json:"email,omitempty"`
	FullName          string `json:"fullName,omitempty"`
	IsEmailVerified   bool   `json:"isEmailVerified,omitempty"`
	IsSecurityCodeSet bool   `json:"isSecurityCodeSet,omitempty"`
	UpdateAccessToken string `json:"updateAccessToken,omitempty"`
}

AccessToken stores response from Login2FAVerify()

type Auth

type Auth struct {
	Token              string      `json:"token,omitempty"`
	TokenSeed          string      `json:"tokenSeed,omitempty"`
	TimeStamp          int         `json:"timeStamp,omitempty"`
	TokenSeedExpiredAt int         `json:"tokenSeedExpiredAt,omitempty"`
	DisplayMessage     interface{} `json:"displayMessage,omitempty"`
	Email              string      `json:"email,omitempty"`
	FullName           string      `json:"fullName,omitempty"`
	IsEmailVerified    bool        `json:"isEmailVerified,omitempty"`
	IsSecurityCodeSet  bool        `json:"isSecurityCodeSet,omitempty"`
	UpdateAccessToken  string      `json:"updateAccessToken,omitempty"`
}

Auth stores response from LoginSecurityCode()

type Balance

type Balance struct {
	OvoPoint OvoPoint `json:"600"`
	OvoMain  OvoMain  `json:"000"`
	OvoCash  OvoCash  `json:"001"`
}

Balance holds balances response

type ErrorResp

type ErrorResp struct {
	Message       string `json:"message,omitempty"`
	Code          int    `json:"code,omitempty"`
	URL           string `json:"url,omitempty"`
	Method        string `json:"method,omitempty"`
	RemoteAddress string `json:"remoteAddress,omitempty"`
	Unixtime      int    `json:"unixtime,omitempty"`
	Retry         int    `json:"retry,omitempty"`
	Timestamp     int    `json:"timestamp,omitempty"`
	Content       struct {
		Present bool `json:"present,omitempty"`
	} `json:"content,omitempty"`
}

ErrorResp stores responses error from ovo API

func (*ErrorResp) Error

func (e *ErrorResp) Error() string

Error for implement error method from error pkg

type Login

type Login struct {
	DeviceID           string `json:"deviceId,omitempty"`
	Mobile             string `json:"mobile,omitempty"`
	AppVersion         string `json:"appVersion,omitempty"`
	MacAddress         string `json:"macAddress,omitempty"`
	OsName             string `json:"osName,omitempty"`
	OsVersion          string `json:"osVersion,omitempty"`
	PushNotificationID string `json:"pushNotificationId,omitempty"`
	RefID              string `json:"refId,omitempty"`
	VerificationCode   string `json:"verificationCode,omitempty"`
	DeviceUnixtime     int64  `json:"deviceUnixtime"`
	SecurityCode       string `json:"securityCode"`
	UpdateAccessToken  string `json:"updateAccessToken"`
	Message            string `json:"message"`
}

Login struct hold needed login field to interact with ovo API

func NewOvoLogin

func NewOvoLogin(phone string) (*Login, error)

NewOvoLogin initialize phone number and get login to ovo API

func (*Login) Login2FA

func (l *Login) Login2FA(ctx context.Context) (*Login2FA, error)

Login2FA login using phone number to OVO

func (*Login) Login2FAVerify

func (l *Login) Login2FAVerify(ctx context.Context, refID, verificationCode string) (*AccessToken, error)

Login2FAVerify is verify OTP sent to phonenumber

func (*Login) LoginSecurityCode

func (l *Login) LoginSecurityCode(ctx context.Context, updateAccessToken string) (*Auth, error)

LoginSecurityCode verify login from security pin code and updated access Token

type Login2FA

type Login2FA struct {
	RefID string `json:"refId,omitempty"`
}

Login2FA holds response when call Login2FA

type Notifications

type Notifications struct {
	ID          string      `json:"id"`
	ChannelType string      `json:"channelType"`
	MessageType string      `json:"messageType"`
	Subject     interface{} `json:"subject"`
	Message     string      `json:"message"`
	DateCreated string      `json:"dateCreated"`
	Status      string      `json:"status"`
	Receiver    struct {
		ID   string `json:"id"`
		Type string `json:"type"`
	} `json:"receiver"`
}

Notifications holds response from GetAllNotifications()

type Ovo

type Ovo struct {
	AuthToken string `json:"token,omitempty"`
	Timeout   time.Duration
}

Ovo holds struct token and hold methods

func NewClient

func NewClient(authToken string, timeout time.Duration) (*Ovo, error)

NewClient creates new instance ovo struct inside for authToken

func (*Ovo) GetAllBalances

func (o *Ovo) GetAllBalances(ctx context.Context) (*RespBalance, error)

GetAllBalances gets all balances in account

func (*Ovo) GetAllNotifications

func (o *Ovo) GetAllNotifications(ctx context.Context) ([]Notifications, error)

GetAllNotifications gets all notifications

func (*Ovo) GetBudgets

func (o *Ovo) GetBudgets(ctx context.Context) (*RespBudget, error)

GetBudgets gets all budget in account

func (*Ovo) GetCountUnreadNotifications

func (o *Ovo) GetCountUnreadNotifications(ctx context.Context) (*int, error)

GetCountUnreadNotifications get count number of notification that unread will return pointer of int because the number can be zero

func (*Ovo) GetRefBank

func (o *Ovo) GetRefBank(ctx context.Context) (*RefBank, error)

GetRefBank Get bank referenceID

type OvoCash

type OvoCash struct {
	CardBalance   int    `json:"card_balance"`
	CardNo        string `json:"card_no"`
	PaymentMethod string `json:"payment_method"`
}

OvoCash holds balance from ovocash

type OvoMain

type OvoMain struct {
	CardBalance   int    `json:"card_balance"`
	CardNo        string `json:"card_no"`
	PaymentMethod string `json:"payment_method"`
}

OvoMain holds balance from ovomain

type OvoPoint

type OvoPoint struct {
	CardBalance   float64 `json:"card_balance"`
	CardNo        string  `json:"card_no"`
	PaymentMethod string  `json:"payment_method"`
}

OvoPoint holds balance from ovopoint

type RefBank

type RefBank struct {
	BankTypes []struct {
		ID        int    `json:"id"`
		Name      string `json:"name"`
		Isdefault int    `json:"isdefault"`
		Value     string `json:"value"`
	} `json:"bankTypes"`
	BankTypeDefault interface{} `json:"bankTypeDefault"`
}

RefBank holds response GetRefBank()

type RespBalance

type RespBalance struct {
	Balance Balance `json:"balance"`
}

RespBalance holds response from GetAllBalance

type RespBudget

type RespBudget struct {
	Budget struct {
		Amount   int `json:"amount"`
		Spending int `json:"spending"`
	} `json:"budget"`
	TotalSpending int `json:"totalSpending"`
	CycleDate     int `json:"cycleDate"`
	Summary       []struct {
		Amount     int `json:"amount"`
		CategoryID int `json:"categoryId"`
		Spending   int `json:"spending"`
	} `json:"summary"`
}

RespBudget holds response from GetAllBudgets()

Jump to

Keyboard shortcuts

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