mytarget_sdk

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: MIT Imports: 6 Imported by: 0

README

MyTarget API SDK GO

Build Status codecov License

Description

MyTarget API Client for Go

API documentation

https://target.my.com/help/partners/management_api/ru

https://target.my.com/adv/api-marketing/doc/stat-v2

https://target.my.com/help/partners/reporting_api_statistics/ru

Download

go get github.com/kachit/mytarget-sdk-go

Usage

package main

import (
    "fmt"
    "net/http"
    mytarget_sdk "github.com/kachit/mytarget-sdk-go"
)

func yourFuncName(){ 
    accessToken := "Access token"
    client := mytarget_sdk.NewClientFromCredentials(accessToken, &http.Client{})

    filter := &marketing.StatsFilter{}
    filter.DateFrom = time.Date(2020, time.Month(9), 1, 0, 0, 0, 0, time.UTC)
    filter.DateTo = time.Date(2020, time.Month(9), 2, 0, 0, 0, 0, time.UTC)
    response, err := client.Marketing().Statistics().GetCampaignStatsDaily(filter)

    if response.IsSuccess() {
        var stats marketing.StatsCollection
        response.Unmarshal(&stats)
        fmt.Println(stats.Items[0].Id)
        fmt.Println(stats.Total.Base.Clicks)
    } else {
        errorRes, _ := response.GetError()
        fmt.Println(errorRes.Error.Code)
        fmt.Println(errorRes.Error.Message)
    }

    fmt.Println(err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClientFromConfig

func NewClientFromConfig(config *config.Config, cl *http.Client) *Client

func NewClientFromCredentials

func NewClientFromCredentials(accessToken string, cl *http.Client) *Client

func (*Client) Management

func (c *Client) Management() *management.Factory

func (*Client) Marketing

func (c *Client) Marketing() *marketing.Factory

func (*Client) Reporting

func (c *Client) Reporting() *reporting.Factory

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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