dgkala

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2017 License: MIT Imports: 7 Imported by: 1

README

Build Status Go Report Card Coverage Status GoDoc license

dgkala

This is a simple Go package to interact with Digikala website.

Installation

go get github.com/mamal72/dgkala

Usage

package main

import (
    "fmt"

    "github.com/mamal72/dgkala"
)

func main() {
    // Get incredible offers
    offers, err := dgkala.IncredibleOffers() // []IncredibleOffer, error
    fmt.Printf("%+v\n", offers)

    // Search for a product by a string keyword
    searchResult, err := dgkala.Search("case-logic-dlbp") // SearchResult, error
    fmt.Printf("%+v\n", searchResult)

    // Get details of a product by ID
    productByID, err := dgkala.GetProductByID(6071) // ProductByID, error
    fmt.Printf("%+v\n", productByID)
}

Tests

go test

Ideas || Issues

Just fill an issue and describe it. I'll check it ASAP!

Contribution

You can fork the repository, improve or fix some part of it and then send the pull requests back if you want to see them here. I really appreciate that. ❤

Remember to write a few tests for your code before sending pull requests.

License

Licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImagePaths added in v1.1.0

type ImagePaths struct {
	Original, Size70, Size110, Size180, Size220 string
}

ImagePaths contains a product images in various sizes

type IncredibleOffer

type IncredibleOffer struct {
	ID                 uint
	ProductID          uint
	Title              string
	ImagePaths         ImagePaths
	BannerPath         string
	BannerPathMobile   string
	BannerPathTablet   string
	Row                uint
	ProductTitleFa     string
	ProductTitleEn     string
	Discount           uint
	Price              uint
	OnlyForApplication bool
	OnlyForMembers     bool
}

IncredibleOffer is a struct containing DGKala incredible offer properties

func IncredibleOffers

func IncredibleOffers() ([]IncredibleOffer, error)

IncredibleOffers get a slice of DGKala IncredibleOffer items

type ProductByID added in v1.1.0

type ProductByID struct {
	ID                uint   `json:"ProductId"`
	EnglishTitle      string `json:"EnTitle"`
	PersianTitle      string `json:"FaTitle"`
	Description       string
	ImagePaths        ImagePaths
	IsIncredibleOffer bool
	Strengths         string
	Weaknesses        string
	MinPrice          uint
}

ProductByID is a struct containing a product details when you get it by ID

func GetProductByID added in v1.1.0

func GetProductByID(productID int) (ProductByID, error)

GetProductByID returns a product by getting it's ID

type ProductByIDResult added in v1.1.0

type ProductByIDResult struct {
	Data ProductByID
}

ProductByIDResult returns a struct containing results of the request for product details by ID

type ProductColor

type ProductColor struct {
	Title string
	Hex   string
	Code  string
}

ProductColor is a struct with properties of products colors

type ProductExistsStatus

type ProductExistsStatus int

ProductExistsStatus is a iota type for product existing status for buying

const (

	// Available means the product is available to buy
	Available ProductExistsStatus
	// OutOfStock means the product is not available  now and is out of stock
	OutOfStock
	// Discontinued means the product is discontinued
	Discontinued
)

type ProductSearchResult

type ProductSearchResult struct {
	ID                  int64
	EnglishTitle        string
	PersianTitle        string
	Image               string
	ExistsStatus        ProductExistsStatus
	IsActive            bool
	URL                 string
	Rate                int64
	MinimumPrice        int64
	MaximumPrice        int64
	Likes               int64
	LastPeriodLikes     int64
	Views               int64
	LastPeriodViews     int64
	IsSpecialOffer      bool
	RegisteredDateTime  time.Time
	HasVideo            bool
	Colors              []ProductColor
	UserRatingCount     int64
	Favorites           int64
	LastPeriodFavorites int64
	LastPeriodSales     int64
	HasGift             bool
	HTMLDetails         string
}

ProductSearchResult is a struct containing a product details for a search result

type SearchResult

type SearchResult struct {
	ResponseTime int64
	Count        int64
	Results      []ProductSearchResult
}

SearchResult returns a struct containing results of the search for a keyword

func Search(keyword string) (SearchResult, error)

Search for a product in DGKala and return a slice of DGKala SearchResult items

Jump to

Keyboard shortcuts

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