github.com/schmorrison/Zoho@v1.1.4/crm/organization.go (about)

     1  package crm
     2  
     3  import (
     4  	"fmt"
     5  
     6  	zoho "github.com/schmorrison/Zoho"
     7  )
     8  
     9  // GetOrganization will return the organization data related to the logged in account
    10  // https://www.zoho.com/crm/help/api/v2/#Organization-API
    11  func (c *API) GetOrganization() (data OrganizationResponse, err error) {
    12  	endpoint := zoho.Endpoint{
    13  		Name:         "organization",
    14  		URL:          fmt.Sprintf("https://www.zohoapis.%s/crm/v2/org", c.ZohoTLD),
    15  		Method:       zoho.HTTPGet,
    16  		ResponseData: &OrganizationResponse{},
    17  	}
    18  
    19  	err = c.Zoho.HTTPRequest(&endpoint)
    20  	if err != nil {
    21  		return OrganizationResponse{}, fmt.Errorf("Failed to retrieve organization: %s", err)
    22  	}
    23  
    24  	if v, ok := endpoint.ResponseData.(*OrganizationResponse); ok {
    25  		return *v, nil
    26  	}
    27  
    28  	return OrganizationResponse{}, fmt.Errorf("Data retrieved was not 'OrganizationResponse'")
    29  }
    30  
    31  // OrganizationResponse is the data returned by GetOrganization
    32  type OrganizationResponse struct {
    33  	Org []struct {
    34  		Country        string `json:"country,omitempty"`
    35  		McStatus       bool   `json:"mc_status,omitempty"`
    36  		GappsEnabled   bool   `json:"gapps_enabled,omitempty"`
    37  		ID             string `json:"id,omitempty"`
    38  		State          string `json:"state,omitempty"`
    39  		EmployeeCount  string `json:"employee_count,omitempty"`
    40  		Website        string `json:"website,omitempty"`
    41  		CurrencySymbol string `json:"currency_symbol,omitempty"`
    42  		Mobile         string `json:"mobile,omitempty"`
    43  		CurrencyLocale string `json:"currency_locale,omitempty"`
    44  		PrimaryZuid    string `json:"primary_zuid,omitempty"`
    45  		Zgid           string `json:"zgid,omitempty"`
    46  		CountryCode    string `json:"country_code,omitempty"`
    47  		LicenseDetails struct {
    48  			PaidExpiry            Time   `json:"paid_expiry,omitempty"`
    49  			UsersLicensePurchased int    `json:"users_license_purchased,omitempty"`
    50  			TrialType             string `json:"trial_type,omitempty"`
    51  			TrialExpiry           Time   `json:"trial_expiry,omitempty"`
    52  			Paid                  bool   `json:"paid,omitempty"`
    53  			PaidType              string `json:"paid_type,omitempty"`
    54  		} `json:"license_details,omitempty"`
    55  		CompanyName     string `json:"company_name,omitempty"`
    56  		PrivacySettings bool   `json:"privacy_settings,omitempty"`
    57  		PrimaryEmail    string `json:"primary_email,omitempty"`
    58  		IsoCode         string `json:"iso_code,omitempty"`
    59  	} `json:"org,omitempty"`
    60  }