expense

package
v0.0.0-...-72ca5cb Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

README

Zoho EXPENSE V1 API

NOTE: Not finished and probably unstable. PRs welcome.

This API wrapper should provide access to Zoho EXPENSE. Because some fields exist only in add-ons for EXPENSE, or are custom fields, which cannot be easily differentiated, all fields that are recieved in a record which have no direct corresponding field in the defined struct will be available in a map[string]interface{} field. This may extend to all fields being accessible in a field called "RAW" or some-such, which can then be manually type-asserted against.

Note: These APIs result entire API response in JSON format. It is expected that client application will parse the API response to get the desired fields. fields they need.

Usage

import (
    "log"
    "fmt"
    "github.com/schmorrison/Zoho"
)

func main() {
    // get access/refresh tokens
    z := zoho.New()
    scopes := []zoho.ScopeString{
        zoho.BuildScope(zoho.Expense, zoho.FullAccessScope, zoho.AllMethod, zoho.NoOp),
    }
    if err := z.AuthorizationCodeRequest("yourClientID", "yourClientSecret", scopes, "http://localhost:8080/oauthredirect"); err != nil {
        log.Fatal(err)
    }

    // Create a new Expense object and provide the zoho master struct
    c := expense.New(z)

    // While untested, getting data should work like so
    data := expense.ExpenseReportResponse{}
    _, err := c.GetExpenseReports(&data, "yourorganizationid", nil)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(data)
}

TODO

  • Write a TODO list
  • Comment code with full details
  • Add page context values to returned data, or methods to interact with it via module
  • Create godoc for expense APIs
  • Identify Expense APIs which are used most

Documentation

Index

Constants

View Source
const (
	ExpenseAPIEndPoint     expenseModule = "https://expense.zoho.com/api/v1/"
	OrganizationsModule    expenseModule = "organizations"
	ExpenseReportModule    expenseModule = "expensereports"
	ExpensesModule         expenseModule = "expenses"
	TripsModule            expenseModule = "trips"
	ExpenseCategoiesModule expenseModule = "expensecategories"
	UsersModule            expenseModule = "users"
	CustomersModule        expenseModule = "contacts"
	ProjectsModule         expenseModule = "projects"
	CurrenciesModule       expenseModule = "settings/currencies"
	TaxesModule            expenseModule = "settings/taxes"
)

Change here only if these values changes over time

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	*zoho.Zoho
	// contains filtered or unexported fields
}

API is used for interacting with the Zoho expense API the exposed methods are primarily access to expense modules which provide access to expense Methods

func New

func New(z *zoho.Zoho) *API

New returns a *expense.API with the provided zoho.Zoho as an embedded field

func (*API) GetExpenseReports

func (c *API) GetExpenseReports(request interface{}, organizationId string, params map[string]zoho.Parameter) (data ExpenseReportResponse, err error)

GetExpenseReports will return a list of all submitted expense reports as specified by https://www.zoho.com/expense/api/v1/#Expense_Reports_List_of_all_expense_reports

func (*API) GetOrganization

func (c *API) GetOrganization() (data OrganizationResponse, err error)

Alternatively organization_id can also be known after login to zoho web page at https://expense.zoho.com/app#/organizations

type ExpenseReportResponse

type ExpenseReportResponse struct {
	Code           int `json:"code"`
	ExpenseReports []struct {
		ApprovedDate  string `json:"approved_date"`
		ApproverEmail string `json:"approver_email"`
		ApproverID    string `json:"approver_id"`
		ApproverName  string `json:"approver_name"`
		CommentsCount int    `json:"comments_count"`
		CreatedByID   string `json:"created_by_id"`
		CreatedByName string `json:"created_by_name"`
		CreatedTime   string `json:"created_time"`
		CurrencyCode  string `json:"currency_code"`
		CurrencyID    string `json:"currency_id"`
		CustomFields  []struct {
			CustomfieldID string `json:"customfield_id"`
			Label         string `json:"label"`
			Value         string `json:"value"`
		} `json:"custom_fields"`
		CustomerID                string  `json:"customer_id"`
		CustomerName              string  `json:"customer_name"`
		Description               string  `json:"description"`
		DueDate                   string  `json:"due_date"`
		DueDays                   string  `json:"due_days"`
		EndDate                   string  `json:"end_date"`
		IsArchived                bool    `json:"is_archived"`
		LastModifiedTime          string  `json:"last_modified_time"`
		LastSubmittedDate         string  `json:"last_submitted_date"`
		NonReimbursableTotal      float64 `json:"non_reimbursable_total"`
		PolicyID                  string  `json:"policy_id"`
		PolicyName                string  `json:"policy_name"`
		PolicyViolated            bool    `json:"policy_violated"`
		ProjectID                 string  `json:"project_id"`
		ProjectName               string  `json:"project_name"`
		ReimbursableTotal         float64 `json:"reimbursable_total"`
		ReimbursementDate         string  `json:"reimbursement_date"`
		ReportID                  string  `json:"report_id"`
		ReportName                string  `json:"report_name"`
		ReportNumber              string  `json:"report_number"`
		StartDate                 string  `json:"start_date"`
		Status                    string  `json:"status"`
		SubmittedBy               string  `json:"submitted_by"`
		SubmittedDate             string  `json:"submitted_date"`
		SubmittedToEmail          string  `json:"submitted_to_email"`
		SubmittedToID             string  `json:"submitted_to_id"`
		SubmittedToName           string  `json:"submitted_to_name"`
		SubmitterEmail            string  `json:"submitter_email"`
		SubmitterName             string  `json:"submitter_name"`
		Total                     float64 `json:"total"`
		UncategorizedExpenseCount float64 `json:"uncategorized_expense_count"`
	} `json:"expense_reports"`
	Message string `json:"message"`
}

ExpenseReportResponse is the data returned by GetExpenseReports

type OrganizationResponse

type OrganizationResponse struct {
	Code          int    `json:"code"`
	Message       string `json:"message"`
	Organizations []struct {
		AccountCreatedDate   string `json:"account_created_date"`
		ContactName          string `json:"contact_name"`
		CurrencyCode         string `json:"currency_code"`
		CurrencyFormat       string `json:"currency_format"`
		CurrencyID           string `json:"currency_id"`
		CurrencySymbol       string `json:"currency_symbol"`
		Email                string `json:"email"`
		FiscalYearStartMonth int    `json:"fiscal_year_start_month"`
		IsDefaultOrg         bool   `json:"is_default_org"`
		IsOrgActive          bool   `json:"is_org_active"`
		LanguageCode         string `json:"language_code"`
		Name                 string `json:"name"`
		OrganizationID       string `json:"organization_id"`
		PricePrecision       int    `json:"price_precision"`
		TimeZone             string `json:"time_zone"`
	} `json:"organizations"`
}

OrganizationResponse is the data returned by GetOrganization

Jump to

Keyboard shortcuts

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