profitshare

package module
v0.0.0-...-7f69d0e Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2015 License: MIT Imports: 10 Imported by: 0

README

Currently Implemented:

  • Grabbing the list of Advertisers with Commissions
  • Grabbing current Campaigns with Banners
  • Grabbing Products with Advertiser ID filtering

Grabbing the list of advertisers

package main

import (
	"fmt"
	"github.com/claudiu/go-profitshare"
)

func main() {
	ps := profitshare.NewProfitShare(
		"api user",
		"api key",
	)

	advertisers, err := ps.GetAdvertisers1M()

  if err != nil {
    panic(err)
  }

	for _, advertiser := range advertisers {
		fmt.Println(advertiser.ID)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Error struct {
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
}

APIError holds API error information

type Advertiser

type Advertiser struct {
	ID                 string        `json:"id"`
	Name               string        `json:"name"`
	Category           string        `json:"category"`
	URL                string        `json:"url"`
	LastUpdateProducts string        `json:"last_update_products"`
	Commissions        []Commissions `json:"commissions"`
}

Advertiser instance

type Banner struct {
	Width  int    `json:"width"`
	Height int    `json:"height"`
	Src    string `json:"src"`
}

Banner holds Campaign banner information

type Campaign

type Campaign struct {
	ID             int               `json:"id"`
	AdvertiserID   int               `json:"advertiser_id"`
	Name           string            `json:"name"`
	CommissionType string            `json:"commissionType"`
	StartDate      string            `json:"startDate"`
	EndDate        string            `json:"endDate"`
	PageURL        string            `json:"url"`
	Banners        map[string]Banner `json:"banners"`
}

Campaign holds Campaign information

type CampaignsResult

type CampaignsResult struct {
	Paginator Paginator  `json:"paginator"`
	Campaigns []Campaign `json:"campaigns"`
}

CampaignsResult holds the result of the affiliate-campaigns API call

type Commissions

type Commissions struct {
	CommissionType string `json:"type"`
	Value          string `json:"value"`
}

Commissions instance

type Paginator

type Paginator struct {
	ItemsPerPage int `json:"itemsPerPage"`
	CurrentPage  int `json:"currentPage"`
	TotalPages   int `json:"totalPages"`
}

type Product

type Product struct {
	AdvertiserID    int     `json:"advertiser_id"`
	AdvertiserName  string  `json:"advertiser_name"`
	BrandName       string  `json:"brand_name"`
	CategoryName    string  `json:"category_name"`
	Description     string  `json:"description"`
	FreeShipping    int     `json:"free_shipping"`
	Image           string  `json:"image"`
	ImageOriginal   string  `json:"image_original"`
	LastUpdate      string  `json:"last_update"`
	Link            string  `json:"link"`
	Name            string  `json:"name"`
	PartNumber      string  `json:"part_number"`
	Price           float64 `json:"price"`
	PriceDiscounted string  `json:"price_discounted"`
	PriceVat        float64 `json:"price_vat"`
}

Product holds information about a certain product

type ProductsResult

type ProductsResult struct {
	Result struct {
		CurrentPage    int       `json:"current_page"`
		RecordsPerPage int       `json:"records_per_page"`
		TotalPages     int       `json:"total_pages"`
		Products       []Product `json:"products"`
	} `json:"result"`
}

ProductsResult holds the result from the API

type ProfitShare

type ProfitShare struct {
	SleepTime time.Duration
	// contains filtered or unexported fields
}

ProfitShare API instance

func NewProfitShare

func NewProfitShare(user, key string) (ps *ProfitShare)

Creates a new Instance of ProfitShare API

func (*ProfitShare) Get

func (ps *ProfitShare) Get(uri string) ([]byte, error)

func (*ProfitShare) GetAdvertisers

func (ps *ProfitShare) GetAdvertisers(from time.Time, to time.Time) ([]Advertiser, error)

GetAdvertisers returns a list of advertise from a period of time to another

func (*ProfitShare) GetAdvertisers1D

func (ps *ProfitShare) GetAdvertisers1D() ([]Advertiser, error)

GetAdvertisers1D returns a list of advertisers from a day ago to now

func (*ProfitShare) GetAdvertisers1M

func (ps *ProfitShare) GetAdvertisers1M() ([]Advertiser, error)

GetAdvertisers1M returns a list of advertisers from a month ago to now

func (*ProfitShare) GetCampaignPage

func (ps *ProfitShare) GetCampaignPage(page int) ([]Campaign, Paginator, error)

GetCampaignPage returns all the campaigns from the supplied page

func (*ProfitShare) GetCampaigns

func (ps *ProfitShare) GetCampaigns() ([]Campaign, error)

GetCampaigns returns all the active campaigns

func (*ProfitShare) GetProductPage

func (ps *ProfitShare) GetProductPage(advertiserID []int, page int) ([]Product, Paginator, error)

GetProductPage returns a list of products and the paginator for a certain page

func (*ProfitShare) GetProducts

func (ps *ProfitShare) GetProducts(advertiserID []int) ([]Product, error)

GetProducts returns a list of all the products by advertiserIds

Jump to

Keyboard shortcuts

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