client

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStatusCodeUnexpected = errors.New("unexpected status code")
	ErrNotAuthenticated     = errors.New("client not authenticated. Did you called Authenticate?")
	ErrNoEncryptedCode      = errors.New("no encrypted code found. Did you call `RequestCode` before exchanging certs?")
)

Functions

This section is empty.

Types

type AccountFeedResponse added in v0.1.1

type AccountFeedResponse struct {
	Data Data `json:"data"`
}

type Category

type Category string
const (
	AccountLimitSet            Category = "account_limit_set"
	AnticipateEvent            Category = "anticipate_event"
	BillFlowClosed             Category = "bill_flow_closed"
	BillFlowOnOneDayToDueDate  Category = "bill_flow_on_one_day_to_due_date"
	BillFlowPaid               Category = "bill_flow_paid"
	CardActivated              Category = "card_activated"
	CustomerDeviceAuthorized   Category = "customer_device_authorized"
	CustomerInvitationsChanged Category = "customer_invitations_changed"
	CustomerPasswordChanged    Category = "customer_password_changed"
	InitialAccountLimit        Category = "initial_account_limit"
	Payment                    Category = "payment"
	RewardsFee                 Category = "rewards_fee"
	RewardsRedemption          Category = "rewards_redemption"
	RewardsSignup              Category = "rewards_signup"
	Transaction                Category = "transaction"
	TransactionReversed        Category = "transaction_reversed"
	Tutorial                   Category = "tutorial"
	Welcome                    Category = "welcome"
)

type Charges

type Charges struct {
	Count  int64 `json:"count"`
	Amount int64 `json:"amount"`
}

type Client

type Client interface {
	RequestCode(ctx context.Context, login, password, deviceID string) (*Code, error)
	Authenticate(ctx context.Context, cpf, password string) error
	GetEvents(ctx context.Context) (*EventResponse, error)
	GetAccountFeed(ctx context.Context) ([]Feed, error)
}

func New

func New(opts ...Option) (Client, error)

type Code

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

func (*Code) ExchangeCerts

func (g *Code) ExchangeCerts(ctx context.Context, code string) (string, string, error)

type Data added in v0.1.1

type Data struct {
	Viewer Viewer `json:"viewer"`
}

type Details

type Details struct {
	Subcategory         Subcategory `json:"subcategory"`
	Lat                 *float64    `json:"lat,omitempty"`
	Lon                 *float64    `json:"lon,omitempty"`
	Fx                  *Fx         `json:"fx,omitempty"`
	Charges             *Charges    `json:"charges,omitempty"`
	ChargebackRequested *bool       `json:"chargeback_requested,omitempty"`
	Tags                []string    `json:"tags"`
}

type EventElement

type EventElement struct {
	Description      *string     `json:"description,omitempty"`
	Category         Category    `json:"category"`
	Amount           *int64      `json:"amount,omitempty"`
	Time             time.Time   `json:"time"`
	Source           *Source     `json:"source,omitempty"`
	Title            string      `json:"title"`
	AmountWithoutIof *int64      `json:"amount_without_iof,omitempty"`
	Account          *string     `json:"account,omitempty"`
	Details          *Details    `json:"details,omitempty"`
	ID               string      `json:"id"`
	Links            *EventLinks `json:"_links,omitempty"`
	Tokenized        *bool       `json:"tokenized,omitempty"`
	Href             *string     `json:"href,omitempty"`
}
type EventLinks struct {
	Self Updates `json:"self"`
}

type EventResponse

type EventResponse struct {
	Events     []EventElement     `json:"events"`
	CustomerID string             `json:"customer_id"`
	AsOf       time.Time          `json:"as_of"`
	Links      EventResponseLinks `json:"_links"`
}
type EventResponseLinks struct {
	Updates Updates `json:"updates"`
}

type Feed added in v0.1.1

type Feed struct {
	ID                 string    `json:"id"`
	Typename           string    `json:"__typename"`
	Title              string    `json:"title"`
	Detail             string    `json:"detail"`
	PostDate           string    `json:"postDate"`
	Amount             *float64  `json:"amount"`
	DestinationAccount *NAccount `json:"destinationAccount,omitempty"`
	OriginAccount      *NAccount `json:"originAccount"`
}

type Fx

type Fx struct {
	CurrencyOrigin      string  `json:"currency_origin"`
	AmountOrigin        int64   `json:"amount_origin"`
	AmountUsd           int64   `json:"amount_usd"`
	PreciseAmountOrigin string  `json:"precise_amount_origin"`
	PreciseAmountUsd    string  `json:"precise_amount_usd"`
	ExchangeRate        float64 `json:"exchange_rate"`
}

type NAccount added in v0.1.1

type NAccount struct {
	Name string `json:"name"`
}

type Option

type Option func(*client) error

func WithCertificate

func WithCertificate(certPath, keyPath string) Option

type SavingsAccount added in v0.1.1

type SavingsAccount struct {
	ID   string `json:"id"`
	Feed []Feed `json:"feed"`
}

type Source

type Source string
const (
	InstallmentsMerchant Source = "installments_merchant"
	UpfrontForeign       Source = "upfront_foreign"
	UpfrontNational      Source = "upfront_national"
)

type Subcategory

type Subcategory string
const (
	CardNotPresent Subcategory = "card_not_present"
	CardPresent    Subcategory = "card_present"
	Unknown        Subcategory = "unknown"
)

type Updates

type Updates struct {
	Href string `json:"href"`
}

type Viewer added in v0.1.1

type Viewer struct {
	SavingsAccount SavingsAccount `json:"savingsAccount"`
}

Jump to

Keyboard shortcuts

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