github.com/stripe/stripe-go/v76@v76.25.0/terminal_location.go (about)

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  package stripe
     8  
     9  import "encoding/json"
    10  
    11  // Deletes a Location object.
    12  type TerminalLocationParams struct {
    13  	Params `form:"*"`
    14  	// The full address of the location.
    15  	Address *AddressParams `form:"address"`
    16  	// The ID of a configuration that will be used to customize all readers in this location.
    17  	ConfigurationOverrides *string `form:"configuration_overrides"`
    18  	// A name for the location.
    19  	DisplayName *string `form:"display_name"`
    20  	// Specifies which fields in the response should be expanded.
    21  	Expand []*string `form:"expand"`
    22  	// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
    23  	Metadata map[string]string `form:"metadata"`
    24  }
    25  
    26  // AddExpand appends a new field to expand.
    27  func (p *TerminalLocationParams) AddExpand(f string) {
    28  	p.Expand = append(p.Expand, &f)
    29  }
    30  
    31  // AddMetadata adds a new key-value pair to the Metadata.
    32  func (p *TerminalLocationParams) AddMetadata(key string, value string) {
    33  	if p.Metadata == nil {
    34  		p.Metadata = make(map[string]string)
    35  	}
    36  
    37  	p.Metadata[key] = value
    38  }
    39  
    40  // Returns a list of Location objects.
    41  type TerminalLocationListParams struct {
    42  	ListParams `form:"*"`
    43  	// Specifies which fields in the response should be expanded.
    44  	Expand []*string `form:"expand"`
    45  }
    46  
    47  // AddExpand appends a new field to expand.
    48  func (p *TerminalLocationListParams) AddExpand(f string) {
    49  	p.Expand = append(p.Expand, &f)
    50  }
    51  
    52  // A Location represents a grouping of readers.
    53  //
    54  // Related guide: [Fleet management](https://stripe.com/docs/terminal/fleet/locations)
    55  type TerminalLocation struct {
    56  	APIResource
    57  	Address *Address `json:"address"`
    58  	// The ID of a configuration that will be used to customize all readers in this location.
    59  	ConfigurationOverrides string `json:"configuration_overrides"`
    60  	Deleted                bool   `json:"deleted"`
    61  	// The display name of the location.
    62  	DisplayName string `json:"display_name"`
    63  	// Unique identifier for the object.
    64  	ID string `json:"id"`
    65  	// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
    66  	Livemode bool `json:"livemode"`
    67  	// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
    68  	Metadata map[string]string `json:"metadata"`
    69  	// String representing the object's type. Objects of the same type share the same value.
    70  	Object string `json:"object"`
    71  }
    72  
    73  // TerminalLocationList is a list of Locations as retrieved from a list endpoint.
    74  type TerminalLocationList struct {
    75  	APIResource
    76  	ListMeta
    77  	Data []*TerminalLocation `json:"data"`
    78  }
    79  
    80  // UnmarshalJSON handles deserialization of a TerminalLocation.
    81  // This custom unmarshaling is needed because the resulting
    82  // property may be an id or the full struct if it was expanded.
    83  func (t *TerminalLocation) UnmarshalJSON(data []byte) error {
    84  	if id, ok := ParseID(data); ok {
    85  		t.ID = id
    86  		return nil
    87  	}
    88  
    89  	type terminalLocation TerminalLocation
    90  	var v terminalLocation
    91  	if err := json.Unmarshal(data, &v); err != nil {
    92  		return err
    93  	}
    94  
    95  	*t = TerminalLocation(v)
    96  	return nil
    97  }