// Copyright 2016 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package github

import (
	
	
)

// TrafficReferrer represent information about traffic from a referrer .
type TrafficReferrer struct {
	Referrer *string `json:"referrer,omitempty"`
	Count    *int    `json:"count,omitempty"`
	Uniques  *int    `json:"uniques,omitempty"`
}

// TrafficPath represent information about the traffic on a path of the repo.
type TrafficPath struct {
	Path    *string `json:"path,omitempty"`
	Title   *string `json:"title,omitempty"`
	Count   *int    `json:"count,omitempty"`
	Uniques *int    `json:"uniques,omitempty"`
}

// TrafficData represent information about a specific timestamp in views or clones list.
type TrafficData struct {
	Timestamp *Timestamp `json:"timestamp,omitempty"`
	Count     *int       `json:"count,omitempty"`
	Uniques   *int       `json:"uniques,omitempty"`
}

// TrafficViews represent information about the number of views in the last 14 days.
type TrafficViews struct {
	Views   []*TrafficData `json:"views,omitempty"`
	Count   *int           `json:"count,omitempty"`
	Uniques *int           `json:"uniques,omitempty"`
}

// TrafficClones represent information about the number of clones in the last 14 days.
type TrafficClones struct {
	Clones  []*TrafficData `json:"clones,omitempty"`
	Count   *int           `json:"count,omitempty"`
	Uniques *int           `json:"uniques,omitempty"`
}

// TrafficBreakdownOptions specifies the parameters to methods that support breakdown per day or week.
// Can be one of: day, week. Default: day.
type TrafficBreakdownOptions struct {
	Per string `url:"per,omitempty"`
}

// ListTrafficReferrers list the top 10 referrers over the last 14 days.
//
// GitHub API docs: https://docs.github.com/rest/metrics/traffic#get-top-referral-sources
//
//meta:operation GET /repos/{owner}/{repo}/traffic/popular/referrers
func ( *RepositoriesService) ( context.Context, ,  string) ([]*TrafficReferrer, *Response, error) {
	 := fmt.Sprintf("repos/%v/%v/traffic/popular/referrers", , )

	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

	var  []*TrafficReferrer
	,  := .client.Do(, , &)
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// ListTrafficPaths list the top 10 popular content over the last 14 days.
//
// GitHub API docs: https://docs.github.com/rest/metrics/traffic#get-top-referral-paths
//
//meta:operation GET /repos/{owner}/{repo}/traffic/popular/paths
func ( *RepositoriesService) ( context.Context, ,  string) ([]*TrafficPath, *Response, error) {
	 := fmt.Sprintf("repos/%v/%v/traffic/popular/paths", , )

	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

	var  []*TrafficPath
	,  := .client.Do(, , &)
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// ListTrafficViews get total number of views for the last 14 days and breaks it down either per day or week.
//
// GitHub API docs: https://docs.github.com/rest/metrics/traffic#get-page-views
//
//meta:operation GET /repos/{owner}/{repo}/traffic/views
func ( *RepositoriesService) ( context.Context, ,  string,  *TrafficBreakdownOptions) (*TrafficViews, *Response, error) {
	 := fmt.Sprintf("repos/%v/%v/traffic/views", , )
	,  := addOptions(, )
	if  != nil {
		return nil, nil, 
	}

	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

	 := new(TrafficViews)
	,  := .client.Do(, , &)
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// ListTrafficClones get total number of clones for the last 14 days and breaks it down either per day or week for the last 14 days.
//
// GitHub API docs: https://docs.github.com/rest/metrics/traffic#get-repository-clones
//
//meta:operation GET /repos/{owner}/{repo}/traffic/clones
func ( *RepositoriesService) ( context.Context, ,  string,  *TrafficBreakdownOptions) (*TrafficClones, *Response, error) {
	 := fmt.Sprintf("repos/%v/%v/traffic/clones", , )
	,  := addOptions(, )
	if  != nil {
		return nil, nil, 
	}

	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

	 := new(TrafficClones)
	,  := .client.Do(, , &)
	if  != nil {
		return nil, , 
	}

	return , , nil
}