theperfectgiftcard

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2018 License: MIT Imports: 10 Imported by: 4

README

go-theperfectgiftcard

GoDoc Go Report Card Coverage Status

go-theperfectgiftcard is a go package that parses The Perfect Gift Card website for your gift card summary and transaction history.

To check your card summary and transaction history, The Perfect Gift Card HTTP endpoint requires:

  1. A Gift Card Number.
  2. A Gift Card Pin that is encrypted by an RSA public key.
  3. A set of headers for ASP.Net server.

This package takes your card number and pin, builds headers that are required by the server, encrypts your pin by an RSA public key, then log in to The Perfect Gift Card website and parse the data for you.

Install

go get github.com/ray.ou/go-theperfectgiftcard

Example

package main

import (
	"log"

	"github.com/rayou/go-theperfectgiftcard"
)

func main() {
	cardNo := "1234567890" // change to your card no
	pin := "0000"          // change to your card pin

	client, err := theperfectgiftcard.NewClient()
	if err != nil {
		log.Fatal(err)
	}

	card, resp, err := client.GetCard(cardNo, pin)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Card No: %v", card.CardNo)
	log.Printf("Available Balance: %v", card.AvailableBalance)
	log.Printf("HTTP Status Code: %v", resp.StatusCode)
}

Contributing

PRs are welcome.

Author

Ray Ou - yuhung.ou@live.com

License

MIT.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	CardNo           string
	AccountNo        string
	LoadsToDate      string
	PurchasesToDate  string
	AvailableBalance string
	PurchasedDate    string
	ExpiryDate       string
	Transactions     []Transaction
}

Card contains card summary and transaction history.

type Client

type Client struct {
	BaseURL *url.URL
	// contains filtered or unexported fields
}

Client manages the communicate with the The Perfect Gift Card website.

func NewClient

func NewClient() (*Client, error)

NewClient creates a ThePerfectGiftCard cilent.

func (*Client) GetCard

func (c *Client) GetCard(cardNo string, pin string) (*Card, *Response, error)

GetCard returns a Card struct with card summary and transaction history, a Response which contains a simplied HTTP response, and an error. Takes card number and pin which will be used to login to The Perfect Gift Card website.

type Response

type Response struct {
	*colly.Response
}

Response is a simplied HTTP response. This wraps colly.Response returned from the The Perfect Gift Card website.

type Transaction

type Transaction struct {
	Date        string
	Details     string
	Description string
	Amount      string
	Balance     string
}

Transaction contains the detail of a transaction.

Jump to

Keyboard shortcuts

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