rakutenapi

package module
v0.0.0-...-6e8c745 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 5 Imported by: 0

README

RakutenAPI

for Rakuten affiliate easy search.

	a := RakutenAffiliateAccount{
		ApplicationID: "YOUR APPLICATION ID",
		Status: SearchEnabled,
	}
	api, _ := NewRakutenAPI(a)

	params := map[string]string{}
	params[Format.String()] = "json"
	params[Page.String()] = "1"

	resp, err := api.GetRaktenRunking(params)
	if err != nil {
		t.Fatal(err)
	}
	repr := RankingResponse{}
	json.Unmarshal(resp, &repr)

	fmt.Printf("\n\n\n%+v\n", repr)	

	params = map[string]string{}
	params[Format.String()] = "json"
	params[Page.String()] = "1"
	params[Keyword.String()] = "PS5"

	resp, err = api.GetItemSearch(params)
	if err != nil {
		t.Fatal(err)
	}
	rep := ItemSearchResponse{}
	json.Unmarshal(resp, &rep)

	fmt.Printf("\n\n\n%+v\n", rep)

	params = map[string]string{}
	params[Format.String()] = "json"
	params[Page.String()] = "1"
	params[Keyword.String()] = "東京"

	resp, err = api.GetTravelKeywordSearch(params)
	if err != nil {
		t.Fatal(err)
	}
	reptrv := TravelKeywordSearchResponse{}
	json.Unmarshal(resp, &reptrv)

	fmt.Printf("\n\n\n%+v\n", reptrv)	

Documentation

Index

Constants

View Source
const (
	ItemRankingURL   = "https://app.rakuten.co.jp/services/api/IchibaItem/Ranking/20170628"
	ItemSearchURL    = "https://app.rakuten.co.jp/services/api/IchibaItem/Search/20170706"
	TravelKeyWordURL = "https://app.rakuten.co.jp/services/api/Travel/KeywordHotelSearch/20170426"
)
View Source
const (
	SearchDisabled int = iota
	SearchEnabled
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Hotel

type Hotel struct {
	HotelBasicInfo struct {
		HotelNo             int     `json:"hotelNo"`
		HotelName           string  `json:"hotelName"`
		HotelInformationUrl string  `json:"hotelInformationUrl"`
		PlanListUrl         string  `json:"planListUrl"`
		DpPlanListUrl       string  `json:"dpPlanListUrl"`
		ReviewUrl           string  `json:"reviewUrl"`
		HotelKanaName       string  `json:"hotelKanaName"`
		HotelSpecial        string  `json:"hotelSpecial"`
		HotelMinCharge      int     `json:"hotelMinCharge"`
		Latitude            float64 `json:"latitude"`
		Longitude           float64 `json:"longitude"`
		PostalCode          string  `json:"postalCode"`
		Address1            string  `json:"address1"`
		Address2            string  `json:"address2"`
		TelephoneNo         string  `json:"telephoneNo"`
		FaxNo               string  `json:"faxNo"`
		Access              string  `json:"access"`
		ParkingInformation  string  `json:"parkingInformation"`
		NearestStation      string  `json:"nearestStation"`
		HotelImageUrl       string  `json:"hotelImageUrl"`
		HotelThumbnailUrl   string  `json:"hotelThumbnailUrl"`
		RoomImageUrl        string  `json:"roomImageUrl"`
		RoomThumbnailUrl    string  `json:"roomThumbnailUrl"`
		HotelMapImageUrl    string  `json:"hotelMapImageUrl"`
		ReviewCount         int     `json:"reviewCount"`
		ReviewAverage       float64 `json:"reviewAverage"`
		UserReview          string  `json:"userReview"`
	} `json:"hotelBasicInfo"`
	HotelRatingInfo struct {
		ServiceAverage   float64 `json:"serviceAverage"`
		LocationAverage  float64 `json:"locationAverage"`
		RoomAverage      float64 `json:"roomAverage"`
		EquipmentAverage float64 `json:"equipmentAverage"`
		BathAverage      float64 `json:"bathAverage"`
		MealAverage      float64 `json:"mealAverage"`
	} `json:"hotelRatingInfo"`
}

type Item

type Item struct {
	AffiliateUrl       string   `json:"affiliateUrl"`
	AffiliateRate      float64  `json:"affiliateRate"`
	AsurakuArea        string   `json:"asurakuArea"`
	AsurakuFlag        int      `json:"asurakuFlag"`
	AsurakuClosingTime string   `json:"asurakuClosingTime"`
	Availability       int      `json:"availability"`
	CreditCardFlag     int      `json:"creditCardFlag"`
	Catchcopy          string   `json:"catchcopy"`
	Carrier            int      `json:"carrier"`
	GenreId            int      `json:"genreId"`
	EndTime            string   `json:"endTime"`
	MediumImageUrls    []string `json:"mediumImageUrls"`
	ItemCaption        string   `json:"itemCaption"`
	ImageFlag          int      `json:"imageFlag"`
	ItemCode           string   `json:"itemCode"`
	ItemName           string   `json:"itemName"`
	ItemPrice          int      `json:"itemPrice"`
	ItemUrl            string   `json:"itemUrl"`
	PointRate          int      `json:"pointRate"`
	PointRateEndTime   string   `json:"pointRateEndTime"`
	PointRateStartTime string   `json:"pointRateStartTime"`
	PostageFlag        int      `json:"postageFlag"`
	Rank               int      `json:"rank"`
	ReviewAverage      float64  `json:"reviewAverage"`
	ReviewCount        int      `json:"reviewCount"`
	SmallImageUrls     []string `json:"imageUrl"`
	ShipOverseasArea   string   `json:"shipOverseasArea"`
	ShipOverseasFlag   int      `json:"shipOverseasFlag"`
	ShopAffiliateUrl   string   `json:"shopAffiliateUrl"`
	ShopCode           string   `json:"shopCode"`
	ShopName           string   `json:"shopName"`
	ShopOfTheYearFlag  int      `json:"shopOfTheYearFlag"`
	ShopUrl            string   `json:"shopUrl"`
	StartTime          string   `json:"startTime"`
	TaxFlag            int      `json:"taxFlagmediumImageUrls"`
	TagIds             []int    `json:"tagIds"`
}

FormatVersion 2専用オブジェクト

type ItemSearchResponse

type ItemSearchResponse struct {
	Count            int           `json:"count"`
	Page             int           `json:"page"`
	First            int           `json:"first"`
	Last             int           `json:"last"`
	Hits             int           `json:"hits"`
	Carrier          int           `json:"carrier"`
	PageCount        int           `json:"pageCount"`
	Items            []Item        `json:"Items"`
	GenreInformation []interface{} `json:"GenreInformation"`
	TagInformation   []interface{} `json:"TagInformation"`
}

type RakutenAPI

type RakutenAPI struct {
	RakutenAffiliateAccount
}

func NewRakutenAPI

func NewRakutenAPI(account RakutenAffiliateAccount) (*RakutenAPI, error)

func (*RakutenAPI) GetItemSearch

func (api *RakutenAPI) GetItemSearch(params map[string]string) ([]byte, error)

func (*RakutenAPI) GetRaktenRunking

func (api *RakutenAPI) GetRaktenRunking(params map[string]string) ([]byte, error)

func (*RakutenAPI) GetTravelKeywordSearch

func (api *RakutenAPI) GetTravelKeywordSearch(params map[string]string) ([]byte, error)

type RakutenAffiliateAccount

type RakutenAffiliateAccount struct {
	AffiliateID   string `yaml:"affiliate_id"`
	ApplicationID string `yaml:"app_id"`
	Status        int    `yaml:"status"`
}

type RakutenSearchParameter

type RakutenSearchParameter uint
const (
	// For general use
	ApplicationID RakutenSearchParameter = iota /* Required */
	AffiliateID                                 /* Your affiliate id*/
	Format                                      /* Responsed format "json" or "xml", default "json" */
	CallBack                                    /* For jsonp callback function name */
	Elements                                    /* Elements responsed target columns, default "ALL" */
	FormatVersion                               /* "1" or "2", recommended "2", responsed be a simple. */
	Carrier
	Page
	GenreID /* use Ranking and Search. */

	// For Raunking API use
	Age
	Sex
	Period

	// For ItemSearch API use
	Keyword
	ShopCode
	ItemCode
	TagId
	Hits
	Sort
	MinPrice
	MaxPrice
	Availability
	Field
	ImageFlag
	OrFlag
	NGKeyword
	PurchaseType
	ShipOverseasFlag
	ShipOverseasArea
	AsurakuFlag
	AsurakuArea
	PointRateFlag
	PointRate
	PostageFlag
	CreditCardFlag
	GiftFlag
	HasReviewFlag
	MaxAffiliateRate
	MinAffiliateRate
	HasMovieFlag
	PamphletFlag
	AppointDeliveryDateFlag
	GenreInformationFlag
	TagInformationFlag
)

func (RakutenSearchParameter) String

func (v RakutenSearchParameter) String() string

type RankingResponse

type RankingResponse struct {
	Title         string `json:"title"`
	LastBuildDate string `json:"lastBuildDate"`
	Items         []Item `json:"Items"`
}

type TravelKeywordSearchResponse

type TravelKeywordSearchResponse struct {
	PagingInfo struct {
		RecordCount int `json:"recordCount"`
		PageCount   int `json:"pageCount"`
		Page        int `json:"page"`
		First       int `json:"first"`
		Last        int `json:"last"`
	} `json:"pagingInfo"`
	Hotels [][]Hotel `json:"hotels"`
}

Jump to

Keyboard shortcuts

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