1/**
2 * Copyright 2016 IBM Corp.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *    http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/**
18 * AUTOMATICALLY GENERATED CODE - DO NOT MODIFY
19 */
20
21package services
22
23import (
24	"fmt"
25	"strings"
26
27	"github.com/softlayer/softlayer-go/datatypes"
28	"github.com/softlayer/softlayer-go/session"
29	"github.com/softlayer/softlayer-go/sl"
30)
31
32// The presale event data types indicate the information regarding an individual presale event. The '''locationId''' will indicate the datacenter associated with the presale event. The '''itemId''' will indicate the product item associated with a particular presale event - however these are more rare. The '''startDate''' and '''endDate''' will provide information regarding when the presale event is available for use. At the end of the presale event, the server or services purchased will be available once approved and provisioned.
33type Sales_Presale_Event struct {
34	Session *session.Session
35	Options sl.Options
36}
37
38// GetSalesPresaleEventService returns an instance of the Sales_Presale_Event SoftLayer service
39func GetSalesPresaleEventService(sess *session.Session) Sales_Presale_Event {
40	return Sales_Presale_Event{Session: sess}
41}
42
43func (r Sales_Presale_Event) Id(id int) Sales_Presale_Event {
44	r.Options.Id = &id
45	return r
46}
47
48func (r Sales_Presale_Event) Mask(mask string) Sales_Presale_Event {
49	if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) {
50		mask = fmt.Sprintf("mask[%s]", mask)
51	}
52
53	r.Options.Mask = mask
54	return r
55}
56
57func (r Sales_Presale_Event) Filter(filter string) Sales_Presale_Event {
58	r.Options.Filter = filter
59	return r
60}
61
62func (r Sales_Presale_Event) Limit(limit int) Sales_Presale_Event {
63	r.Options.Limit = &limit
64	return r
65}
66
67func (r Sales_Presale_Event) Offset(offset int) Sales_Presale_Event {
68	r.Options.Offset = &offset
69	return r
70}
71
72// Retrieve A flag to indicate that the presale event is currently active. A presale event is active if the current time is between the start and end dates.
73func (r Sales_Presale_Event) GetActiveFlag() (resp bool, err error) {
74	err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getActiveFlag", nil, &r.Options, &resp)
75	return
76}
77
78// no documentation yet
79func (r Sales_Presale_Event) GetAllObjects() (resp []datatypes.Sales_Presale_Event, err error) {
80	err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getAllObjects", nil, &r.Options, &resp)
81	return
82}
83
84// Retrieve A flag to indicate that the presale event is expired. A presale event is expired if the current time is after the end date.
85func (r Sales_Presale_Event) GetExpiredFlag() (resp bool, err error) {
86	err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getExpiredFlag", nil, &r.Options, &resp)
87	return
88}
89
90// Retrieve The [[SoftLayer_Product_Item]] associated with the presale event.
91func (r Sales_Presale_Event) GetItem() (resp datatypes.Product_Item, err error) {
92	err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getItem", nil, &r.Options, &resp)
93	return
94}
95
96// Retrieve The [[SoftLayer_Location]] associated with the presale event.
97func (r Sales_Presale_Event) GetLocation() (resp datatypes.Location, err error) {
98	err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getLocation", nil, &r.Options, &resp)
99	return
100}
101
102// '''getObject''' retrieves the [[SoftLayer_Sales_Presale_Event]] object whose id number corresponds to the id number of the init parameter passed to the SoftLayer_Sales_Presale_Event service. Customers may only retrieve presale events that are currently active.
103func (r Sales_Presale_Event) GetObject() (resp datatypes.Sales_Presale_Event, err error) {
104	err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getObject", nil, &r.Options, &resp)
105	return
106}
107
108// Retrieve The orders ([[SoftLayer_Billing_Order]]) associated with this presale event that were created for the customer's account.
109func (r Sales_Presale_Event) GetOrders() (resp []datatypes.Billing_Order, err error) {
110	err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getOrders", nil, &r.Options, &resp)
111	return
112}
113