Ejemplo n.º 1
0
func (c *Subscription) List(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (Subscriptions, string, error) {
	endPoint := c.makeEndPointURL(invdendpoint.SubscriptionsEndPoint)
	endPoint = addFilterSortToEndPoint(endPoint, filter, sort)

	expandedValues := invdendpoint.NewExpand()

	expandedValues.Set(defaultExpandSubscription)

	endPoint = addExpandToEndPoint(endPoint, expandedValues)

	subscriptions := make(Subscriptions, 0)

	nextEndPoint, apiErr := c.retrieveDataFromAPI(endPoint, &subscriptions)

	if apiErr != nil {
		return nil, "", apiErr
	}

	for _, subscription := range subscriptions {
		subscription.Connection = c.Connection

	}

	return subscriptions, nextEndPoint, nil

}
Ejemplo n.º 2
0
func (c *Subscription) ListAll(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (Subscriptions, error) {
	endPoint := c.makeEndPointURL(invdendpoint.SubscriptionsEndPoint)
	endPoint = addFilterSortToEndPoint(endPoint, filter, sort)

	expandedValues := invdendpoint.NewExpand()

	expandedValues.Set(defaultExpandSubscription)

	endPoint = addExpandToEndPoint(endPoint, expandedValues)

	subscriptions := make(Subscriptions, 0)

NEXT:
	tmpSubscriptions := make(Subscriptions, 0)

	endPoint, apiErr := c.retrieveDataFromAPI(endPoint, &tmpSubscriptions)

	if apiErr != nil {
		return nil, apiErr
	}

	subscriptions = append(subscriptions, tmpSubscriptions...)

	if endPoint != "" {
		goto NEXT
	}

	for _, subscription := range subscriptions {
		subscription.Connection = c.Connection

	}

	return subscriptions, nil

}
Ejemplo n.º 3
0
func (c *Invoice) Retrieve(id int64) (*Invoice, error) {
	endPoint := makeEndPointSingular(c.makeEndPointURL(invdendpoint.InvoicesEndPoint), id)

	if c.IncludeUpdatedAt {
		endPoint = addIncludeToEndPoint(endPoint, "updated_at")
	}

	expandedValues := invdendpoint.NewExpand()

	expandedValues.Set(defaultExpandInvoice)

	endPoint = addExpandToEndPoint(endPoint, expandedValues)

	custEndPoint := new(invdendpoint.Invoice)

	invoice := &Invoice{c.Connection, custEndPoint, c.IncludeUpdatedAt}

	_, apiErr := c.retrieveDataFromAPI(endPoint, invoice)

	if apiErr != nil {
		return nil, apiErr
	}

	return invoice, nil

}
Ejemplo n.º 4
0
func (c *Invoice) List(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (Invoices, string, error) {
	endPoint := c.makeEndPointURL(invdendpoint.InvoicesEndPoint)
	endPoint = addFilterSortToEndPoint(endPoint, filter, sort)
	if c.IncludeUpdatedAt {
		endPoint = addIncludeToEndPoint(endPoint, "updated_at")
	}

	expandedValues := invdendpoint.NewExpand()

	expandedValues.Set(defaultExpandInvoice)

	endPoint = addExpandToEndPoint(endPoint, expandedValues)

	invoices := make(Invoices, 0)

	nextEndPoint, apiErr := c.retrieveDataFromAPI(endPoint, &invoices)

	if apiErr != nil {
		return nil, "", apiErr
	}

	for _, invoice := range invoices {
		invoice.Connection = c.Connection

	}

	return invoices, nextEndPoint, nil

}
Ejemplo n.º 5
0
func (c *Subscription) Retrieve(id int64) (*Subscription, error) {
	endPoint := makeEndPointSingular(c.makeEndPointURL(invdendpoint.SubscriptionsEndPoint), id)

	expandedValues := invdendpoint.NewExpand()

	expandedValues.Set(defaultExpandSubscription)

	endPoint = addExpandToEndPoint(endPoint, expandedValues)

	custEndPoint := new(invdendpoint.Subscription)

	subscription := &Subscription{c.Connection, custEndPoint}

	_, apiErr := c.retrieveDataFromAPI(endPoint, subscription)

	if apiErr != nil {
		return nil, apiErr
	}

	return subscription, nil

}
Ejemplo n.º 6
0
func (c *Invoice) ListAll(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (Invoices, error) {
	endPoint := c.makeEndPointURL(invdendpoint.InvoicesEndPoint)
	endPoint = addFilterSortToEndPoint(endPoint, filter, sort)

	if c.IncludeUpdatedAt {
		endPoint = addIncludeToEndPoint(endPoint, "updated_at")
	}

	expandedValues := invdendpoint.NewExpand()

	expandedValues.Set(defaultExpandInvoice)

	endPoint = addExpandToEndPoint(endPoint, expandedValues)

	invoices := make(Invoices, 0)

NEXT:
	tmpInvoices := make(Invoices, 0)

	endPoint, apiErr := c.retrieveDataFromAPI(endPoint, &tmpInvoices)

	if apiErr != nil {
		return nil, apiErr
	}

	invoices = append(invoices, tmpInvoices...)

	if endPoint != "" {
		goto NEXT
	}

	for _, invoice := range invoices {
		invoice.Connection = c.Connection

	}

	return invoices, nil

}