github.com/Files-com/files-sdk-go/v2@v2.1.2/bundlerecipient/client.go (about)

     1  package bundle_recipient
     2  
     3  import (
     4  	files_sdk "github.com/Files-com/files-sdk-go/v2"
     5  	lib "github.com/Files-com/files-sdk-go/v2/lib"
     6  	listquery "github.com/Files-com/files-sdk-go/v2/listquery"
     7  )
     8  
     9  type Client struct {
    10  	files_sdk.Config
    11  }
    12  
    13  type Iter struct {
    14  	*files_sdk.Iter
    15  	*Client
    16  }
    17  
    18  func (i *Iter) Reload(opts ...files_sdk.RequestResponseOption) files_sdk.IterI {
    19  	return &Iter{Iter: i.Iter.Reload(opts...).(*files_sdk.Iter), Client: i.Client}
    20  }
    21  
    22  func (i *Iter) BundleRecipient() files_sdk.BundleRecipient {
    23  	return i.Current().(files_sdk.BundleRecipient)
    24  }
    25  
    26  func (c *Client) List(params files_sdk.BundleRecipientListParams, opts ...files_sdk.RequestResponseOption) (*Iter, error) {
    27  	i := &Iter{Iter: &files_sdk.Iter{}, Client: c}
    28  	path, err := lib.BuildPath("/bundle_recipients", params)
    29  	if err != nil {
    30  		return i, err
    31  	}
    32  	i.ListParams = &params
    33  	list := files_sdk.BundleRecipientCollection{}
    34  	i.Query = listquery.Build(c.Config, path, &list, opts...)
    35  	return i, nil
    36  }
    37  
    38  func List(params files_sdk.BundleRecipientListParams, opts ...files_sdk.RequestResponseOption) (*Iter, error) {
    39  	return (&Client{}).List(params, opts...)
    40  }
    41  
    42  func (c *Client) Create(params files_sdk.BundleRecipientCreateParams, opts ...files_sdk.RequestResponseOption) (bundleRecipient files_sdk.BundleRecipient, err error) {
    43  	err = files_sdk.Resource(c.Config, lib.Resource{Method: "POST", Path: "/bundle_recipients", Params: params, Entity: &bundleRecipient}, opts...)
    44  	return
    45  }
    46  
    47  func Create(params files_sdk.BundleRecipientCreateParams, opts ...files_sdk.RequestResponseOption) (bundleRecipient files_sdk.BundleRecipient, err error) {
    48  	return (&Client{}).Create(params, opts...)
    49  }