dmm

package module
v0.0.0-...-1b72d7d Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2016 License: MIT Imports: 10 Imported by: 0

README

dmm.go GoDoc

DMM Web API Client

see: DMM Affiliate

Installation

Standard go get:

$ go get github.com/YusukeKomatsu/dmm.go

Usage

For usage and examples see the Godoc.

Example

api := New("foobarbazbuzz", "dummy-990")
api.SetSite(SITE_ALLAGES)
api.SetService("mono")
api.SetFloor("dvd")
api.SetSort("date")
api.SetLength(1)
result, err := api.Execute()
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(result)
}

OR

rst, err := New("foobarbazbuzz", "dummy-999").SetSite(SITE_ADULT).SetLength(1).Execute()
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(rst)
}

Request parameter

r = *dmm.request

API this library description e.g. how to set parameter
api_id ApiId API ID "KcZ2ymn6VPufm4XjxFu6" r := New("KcZ2ymn6VPufm4XjxFu6", "dummy-999")
affiliate_id AffiliateId affiliate iD dummy-999 r := New("foobarbazbuzz", "dummy-999")
operation Operation API method name ItemList Nothing (operation exists ItemList ONLY)
version Version API version 2.00 Nothing (version 2 ONLY)
timestamp Timestamp timestamp 2006-01-02 15:04:05 Nothing(timestamp is automatically set)
site Site site name (DMM.com or DMM.co.jp) DMM.co.jp r.SetSite("DMM.com")
service Service target service mono r.SetService("mono")
floor Floor target floor dvd r.SetFloor("dvd")
hits Length maximum request length 100 r.SetLength(100)
offset Offset request data offset 0 r.SetOffset(0)
sort Sort response data sort rank r.SetSort("rank")
keyword Keyword request keyword social network r.SetKeyword("social network")

Documentation

Index

Constants

View Source
const (
	SITE_ALLAGES   = "DMM.com"
	SITE_ADULT     = "DMM.co.jp"
	OPERATION_LIST = "ItemList"
	DEFAULT_LENGTH = 20
	DEFAULT_OFFSET = 1
)

Variables

View Source
var (
	API_URL     = "http://affiliate-api.dmm.com/"
	API_VERSION = "2.00"
)

Functions

This section is empty.

Types

type BandaiInformation

type BandaiInformation struct {
	TitleCode string `xml:"titlecode"`
}

type CdInformation

type CdInformation struct {
	Kind string `xml:"kind"`
}

type Distribution

type Distribution struct {
	Type  string `xml:"type"`
	Price string `xml:"price"`
}

type DistributionList

type DistributionList struct {
	Distribution []Distribution `xml:"delivery"`
}

type ImageUrlList

type ImageUrlList struct {
	List  string `xml:"list"`
	Small string `xml:"small"`
	Large string `xml:"large"`
}

type Item

type Item struct {
	ServiceName        string             `xml:"service_name"`
	FloorName          string             `xml:"floor_name"`
	CategoryName       string             `xml:"category_name"`
	ContentId          string             `xml:"content_id"`
	ProductId          string             `xml:"product_id"`
	Title              string             `xml:"title"`
	Url                string             `xml:"URL"`
	UrlMoble           string             `xml:"URLsp"`
	AffiliateUrl       string             `xml:"affiliateURL"`
	AffiliateUrlMobile string             `xml:"affiliateURLsp"`
	Date               string             `xml:"date"`
	JANCode            string             `xml:"jancode"`
	ProductCode        string             `xml:"maker_product"`
	ISBN               string             `xml:"isbn"`
	Stock              string             `xml:"stock"`
	ImageUrl           ImageUrlList       `xml:"imageURL"`
	SampleImageUrl     SampleImageUrlList `xml:"sampleImageURL"`
	PriceInformation   PriceInformation   `xml:"prices"`
	ItemInformation    ItemInformation    `xml:"iteminfo"`
	BandaiInformation  BandaiInformation  `xml:"bandaiinfo"`
	CdInformation      CdInformation      `xml:"cdinfo"`
}

type ItemComponent

type ItemComponent struct {
	Id   string `xml:"id"`
	Name string `xml:"name"`
}

type ItemInformation

type ItemInformation struct {
	Maker     ItemComponent   `xml:"maker"`
	Label     ItemComponent   `xml:"label"`
	Series    ItemComponent   `xml:"series"`
	Keywords  []ItemComponent `xml:"keyword"`
	Genres    []ItemComponent `xml:"genre"`
	Actors    []ItemComponent `xml:"actor"`
	Artists   []ItemComponent `xml:"artist"`
	Authors   []ItemComponent `xml:"author"`
	Directors []ItemComponent `xml:"director"`
	Fighters  []ItemComponent `xml:"fighter"`
	Colors    []ItemComponent `xml:"color"`
	Sizes     []ItemComponent `xml:"size"`
}

type ItemList

type ItemList struct {
	Item []Item `xml:"item"`
}

type PriceInformation

type PriceInformation struct {
	Price         string           `xml:"price"`
	PriceAll      string           `xml:"price_all"`
	RetailPrice   string           `xml:"list_price"`
	Distributions DistributionList `xml:"deliveries"`
}

type Request

type Request struct {
	ApiId       string
	AffiliateId string
	Operation   string
	Version     string
	Timestamp   string
	Site        string
	Service     string
	Floor       string
	Length      int64
	Offset      int64
	Sort        string
	Keyword     string
}

func New

func New(api_id, affiliate_id string) *Request

creates new client Example:

api := New("foobarbazbuzz", "dummy-990")
api.SetSite(SITE_ALLAGES)
api.SetService("mono")
api.SetFloor("dvd")
api.SetSort("date")
api.SetLength(1)
result, err := api.Execute()
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(result)
}

Example:

rst, err := New("foobarbazbuzz", "dummy-999").SetSite(SITE_ADULT).SetLength(1).Execute()
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(rst)
}

func (*Request) Execute

func (req *Request) Execute() (*Response, error)

does API request

func (*Request) SetFloor

func (req *Request) SetFloor(floor string) *Request

set floor parameter see.) https://affiliate.dmm.com/api/reference/com/all/

func (*Request) SetKeyword

func (req *Request) SetKeyword(keyword string) *Request

set keyword parameter

func (*Request) SetLength

func (req *Request) SetLength(length int64) *Request

set hits parameter

func (*Request) SetOffset

func (req *Request) SetOffset(offset int64) *Request

set offset parameter

func (*Request) SetService

func (req *Request) SetService(service string) *Request

set service parameter see.) https://affiliate.dmm.com/api/reference/com/all/

func (*Request) SetSite

func (req *Request) SetSite(site string) *Request

set site parameter site value: DMM.com or DMM.co.jp

func (*Request) SetSort

func (req *Request) SetSort(sort string) *Request

set sort parameter

type Response

type Response struct {
	Result Result `xml:"result"`
}

type Result

type Result struct {
	ResultCount   int64    `xml:"result_count"`
	TotalCount    int64    `xml:"total_count"`
	FirstPosition int64    `xml:"first_position"`
	Items         ItemList `xml:"items"`
}

type SampleImageUrlList

type SampleImageUrlList struct {
	Sample_s SmallSampleList `xml:"sample_s"`
}

type SmallSampleList

type SmallSampleList struct {
	Image []string `xml:"image"`
}

Jump to

Keyboard shortcuts

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