bill

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ApiSessionBaseURL = BaseURL + "/GetSessionInfo.json"
View Source
const BaseURL = "https://api.bill.com/api/v2"
View Source
const LoginBaseURL = BaseURL + "/Login.json"

usual format: <API_Base_URL>/Crud/<Operation>/<Entity>.json (Read more at https://developer.bill.com/docs/api-request-format)

View Source
const OrganizationsBaseURL = BaseURL + "/ListOrgs.json"
View Source
const SandboxBaseURL = "https://api-sandbox.bill.com/api/v2"
View Source
const UserRolePermissionsBaseURL = BaseURL + "/GetProfilePermissions.json"
View Source
const UserRoleProfileBaseURL = BaseURL + "/Crud/Read/Profile.json"
View Source
const UserRoleProfilesBaseURL = BaseURL + "/List/Profile.json"
View Source
const UsersBaseURL = BaseURL + "/List/User.json"

Variables

This section is empty.

Functions

func IsInvalidResponse

func IsInvalidResponse[T any](response BaseResponse[T]) bool

Types

type BaseResource

type BaseResource struct {
	Id string `json:"id"`
}

type BaseResponse

type BaseResponse[T any] struct {
	Status  int    `json:"response_status"`
	Message string `json:"response_message"`
	Data    T      `json:"response_data"`
}

type Client

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

func NewClient

func NewClient(httpClient *http.Client, credentials Credentials) *Client

func (*Client) GetOrganizations

func (c *Client) GetOrganizations(ctx context.Context) ([]Organization, error)

GetOrganization returns detail information about the organization. This operation does not require Login to be called first.

func (*Client) GetSessionDetails

func (c *Client) GetSessionDetails(ctx context.Context) (SessionDetails, error)

GetSessionDetails returns details regarding session of currently signed in user and organization.

func (*Client) GetUserRolePermissions

func (c *Client) GetUserRolePermissions(ctx context.Context, roleId string) (map[string]bool, error)

GetUserRolePermissions returns map of permissions under the provided user role.

func (*Client) GetUserRoleProfile

func (c *Client) GetUserRoleProfile(ctx context.Context, roleId string) (UserRoleProfile, error)

GetUserRoleProfile returns detail information about the user role under provided id.

func (*Client) GetUserRoleProfiles

func (c *Client) GetUserRoleProfiles(ctx context.Context, getUserRoleProfilesVars PaginationParams) ([]UserRoleProfile, int, error)

GetUserRoleProfiles returns all user roles available in the organization.

func (*Client) GetUsers

func (c *Client) GetUsers(ctx context.Context, getUsersVars PaginationParams) ([]User, int, error)

GetUsers returns all users under the organization account.

func (*Client) Login

func (c *Client) Login(ctx context.Context, organizationId string) error

Login logs the user into specific organization and returns the session id and organization id.

type Credentials

type Credentials struct {
	Username       string
	Password       string
	OrganizationId string
	DeveloperKey   string
	SessionId      string
}

func (Credentials) Apply

func (credentials Credentials) Apply(body *url.Values)

Method Apply for Credentials struct adds credentials to the request body.

type Filter

type Filter struct {
	Field string      `json:"field"`
	Op    string      `json:"op"`
	Value interface{} `json:"value"`
}

type LoginData

type LoginData struct {
	SessionId string `json:"sessionId"`
	OrgId     string `json:"orgId"`
}

type LoginResponse

type LoginResponse = BaseResponse[LoginData]

type Organization

type Organization struct {
	Id   string `json:"orgId"`
	Name string `json:"orgName"`
}

type OrganizationsResponse

type OrganizationsResponse = BaseResponse[[]Organization]

type PaginationParams

type PaginationParams struct {
	Max   int `json:"max"`
	Start int `json:"start"`
}

func (PaginationParams) Apply

func (pagination PaginationParams) Apply(body *url.Values)

Method Apply for PaginationParams struct adds pagination parameters to the request body.

type RequestOption

type RequestOption interface {
	Apply(*url.Values)
}

type SearchParams

type SearchParams struct {
	Id        string   `json:"id"`
	Filters   []Filter `json:"filters"`
	Sort      []Sort   `json:"sort"`
	Nested    bool     `json:"nested"`
	ShowAudit bool     `json:"showAudit"`
}

func (SearchParams) Apply

func (searchParams SearchParams) Apply(body *url.Values)

Method Apply for SearchParams struct adds search parameters (like id of the resource) to the request body. In case of Bill.com API, it uses the data field to pass the search parameters as well as the pagination parameters So this function handles both cases.

type SessionDetails

type SessionDetails struct {
	OrgId  string `json:"organizationId"`
	UserId string `json:"userId"`
}

type SessionDetailsResponse

type SessionDetailsResponse = BaseResponse[SessionDetails]

type Sort

type Sort struct {
	Field string `json:"field"`
	Asc   bool   `json:"asc"`
}

type User

type User struct {
	BaseResource
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	Email     string `json:"email"`
	Name      string `json:"name"`
	IsActive  bool   `json:"isActive"`
	RoleId    string `json:"profileId"`
}

type UserParams

type UserParams struct {
	PaginationParams
	SearchParams
}

type UserRolePermissionsResponse

type UserRolePermissionsResponse = BaseResponse[map[string]bool]

type UserRoleProfile

type UserRoleProfile struct {
	BaseResource
	Name        string `json:"name"`
	Type        string `json:"type"`
	Description string `json:"description"`
}

type UserRoleProfileResponse

type UserRoleProfileResponse = BaseResponse[UserRoleProfile]

type UserRoleProfilesResponse

type UserRoleProfilesResponse = BaseResponse[[]UserRoleProfile]

type UsersResponse

type UsersResponse = BaseResponse[[]User]

Jump to

Keyboard shortcuts

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