<commit_before>package dgkala

import (
	"encoding/json"
	"io/ioutil"
	"net/http"
)

const apiAddress = "https://service2.digikala.com/api/IncredibleOffer/GetIncredibleOffer"

// ImagePath is a struct containing the product images in various sizes
type ImagePath struct {
	Original, Size70, Size110, Size180, Size220 string
}

// SpecialOffer is a struct containing
// DGKala special offer properties
type SpecialOffer struct {
	ID                 uint
	ProductID          uint
	Title              string
	ImagePaths         ImagePath
	BannerPath         string
	BannerPathMobile   string
	BannerPathTablet   string
	Row                uint
	ProductTitleFa     string
	ProductTitleEn     string
	Discount           uint
	Price              uint
	OnlyForApplication bool
	OnlyForMembers     bool
}

type specialOffersResponse struct {
	Data   []SpecialOffer
	Status string
}

func sendRequest(address string, headers map[string]string) (*http.Response, error) {
	request, err := http.NewRequest(http.MethodGet, address, nil)
	if err != nil {
		return nil, err
	}

	for key, value := range headers {
		request.Header.Add(key, value)
	}

	client := http.Client{}
	response, err := client.Do(request)
	return response, err
}

// SpecialOffers returns a slice of DGKala SpecialOffer
func SpecialOffers() ([]SpecialOffer, error) {
	headers := map[string]string{"ApplicationVersion": "1.3.2"}
	response, err := sendRequest(apiAddress, headers)
	if err != nil {
		return nil, err
	}

	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return nil, err
	}
	var specialOffersResponse specialOffersResponse
	err = json.Unmarshal(body, &specialOffersResponse)
	if err != nil {
		return nil, err
	}
	specialOffers := specialOffersResponse.Data
	return specialOffers, nil
}<commit_msg>fix(special offers): store reference to offers<commit_after>package dgkala

import (
	"encoding/json"
	"io/ioutil"
	"net/http"
)

const apiAddress = "https://service2.digikala.com/api/IncredibleOffer/GetIncredibleOffer"

// ImagePath is a struct containing the product images in various sizes
type ImagePath struct {
	Original, Size70, Size110, Size180, Size220 string
}

// SpecialOffer is a struct containing
// DGKala special offer properties
type SpecialOffer struct {
	ID                 uint
	ProductID          uint
	Title              string
	ImagePaths         ImagePath
	BannerPath         string
	BannerPathMobile   string
	BannerPathTablet   string
	Row                uint
	ProductTitleFa     string
	ProductTitleEn     string
	Discount           uint
	Price              uint
	OnlyForApplication bool
	OnlyForMembers     bool
}

type specialOffersResponse struct {
	Data   []SpecialOffer
	Status string
}

func sendRequest(address string, headers map[string]string) (*http.Response, error) {
	request, err := http.NewRequest(http.MethodGet, address, nil)
	if err != nil {
		return nil, err
	}

	for key, value := range headers {
		request.Header.Add(key, value)
	}

	client := http.Client{}
	response, err := client.Do(request)
	return response, err
}

// SpecialOffers returns a slice of DGKala SpecialOffer
func SpecialOffers() ([]SpecialOffer, error) {
	headers := map[string]string{"ApplicationVersion": "1.3.2"}
	response, err := sendRequest(apiAddress, headers)
	if err != nil {
		return nil, err
	}

	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return nil, err
	}
	offersResponse := &specialOffersResponse{}
	err = json.Unmarshal(body, offersResponse)
	if err != nil {
		return nil, err
	}
	specialOffers := offersResponse.Data
	return specialOffers, nil
}
{'fraction_non_alphanumeric': 0.08750349454850433, 'fraction_numerical': 0.008386916410399776, 'mean_word_length': 3.4392059553349874, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3561777', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1095, 'n_words': 322}