/*
Hindsight HTTP API

HTTP API for Hindsight

API version: 0.4.17
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package hindsight

import (
	"encoding/json"
	"bytes"
	"fmt"
)

// checks if the RetainResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &RetainResponse{}

// RetainResponse Response model for retain endpoint.
type RetainResponse struct {
	Success bool `json:"success"`
	BankId string `json:"bank_id"`
	ItemsCount int32 `json:"items_count"`
	// Whether the operation was processed asynchronously
	Async bool `json:"async"`
	OperationId NullableString `json:"operation_id,omitempty"`
	Usage NullableTokenUsage `json:"usage,omitempty"`
}

type _RetainResponse RetainResponse

// NewRetainResponse instantiates a new RetainResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewRetainResponse(success bool, bankId string, itemsCount int32, async bool) *RetainResponse {
	this := RetainResponse{}
	this.Success = success
	this.BankId = bankId
	this.ItemsCount = itemsCount
	this.Async = async
	return &this
}

// NewRetainResponseWithDefaults instantiates a new RetainResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewRetainResponseWithDefaults() *RetainResponse {
	this := RetainResponse{}
	return &this
}

// GetSuccess returns the Success field value
func (o *RetainResponse) GetSuccess() bool {
	if o == nil {
		var ret bool
		return ret
	}

	return o.Success
}

// GetSuccessOk returns a tuple with the Success field value
// and a boolean to check if the value has been set.
func (o *RetainResponse) GetSuccessOk() (*bool, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Success, true
}

// SetSuccess sets field value
func (o *RetainResponse) SetSuccess(v bool) {
	o.Success = v
}

// GetBankId returns the BankId field value
func (o *RetainResponse) GetBankId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.BankId
}

// GetBankIdOk returns a tuple with the BankId field value
// and a boolean to check if the value has been set.
func (o *RetainResponse) GetBankIdOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.BankId, true
}

// SetBankId sets field value
func (o *RetainResponse) SetBankId(v string) {
	o.BankId = v
}

// GetItemsCount returns the ItemsCount field value
func (o *RetainResponse) GetItemsCount() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.ItemsCount
}

// GetItemsCountOk returns a tuple with the ItemsCount field value
// and a boolean to check if the value has been set.
func (o *RetainResponse) GetItemsCountOk() (*int32, bool) {
	if o == nil {
		return nil, false
	}
	return &o.ItemsCount, true
}

// SetItemsCount sets field value
func (o *RetainResponse) SetItemsCount(v int32) {
	o.ItemsCount = v
}

// GetAsync returns the Async field value
func (o *RetainResponse) GetAsync() bool {
	if o == nil {
		var ret bool
		return ret
	}

	return o.Async
}

// GetAsyncOk returns a tuple with the Async field value
// and a boolean to check if the value has been set.
func (o *RetainResponse) GetAsyncOk() (*bool, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Async, true
}

// SetAsync sets field value
func (o *RetainResponse) SetAsync(v bool) {
	o.Async = v
}

// GetOperationId returns the OperationId field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *RetainResponse) GetOperationId() string {
	if o == nil || IsNil(o.OperationId.Get()) {
		var ret string
		return ret
	}
	return *o.OperationId.Get()
}

// GetOperationIdOk returns a tuple with the OperationId field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *RetainResponse) GetOperationIdOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return o.OperationId.Get(), o.OperationId.IsSet()
}

// HasOperationId returns a boolean if a field has been set.
func (o *RetainResponse) HasOperationId() bool {
	if o != nil && o.OperationId.IsSet() {
		return true
	}

	return false
}

// SetOperationId gets a reference to the given NullableString and assigns it to the OperationId field.
func (o *RetainResponse) SetOperationId(v string) {
	o.OperationId.Set(&v)
}
// SetOperationIdNil sets the value for OperationId to be an explicit nil
func (o *RetainResponse) SetOperationIdNil() {
	o.OperationId.Set(nil)
}

// UnsetOperationId ensures that no value is present for OperationId, not even an explicit nil
func (o *RetainResponse) UnsetOperationId() {
	o.OperationId.Unset()
}

// GetUsage returns the Usage field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *RetainResponse) GetUsage() TokenUsage {
	if o == nil || IsNil(o.Usage.Get()) {
		var ret TokenUsage
		return ret
	}
	return *o.Usage.Get()
}

// GetUsageOk returns a tuple with the Usage field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *RetainResponse) GetUsageOk() (*TokenUsage, bool) {
	if o == nil {
		return nil, false
	}
	return o.Usage.Get(), o.Usage.IsSet()
}

// HasUsage returns a boolean if a field has been set.
func (o *RetainResponse) HasUsage() bool {
	if o != nil && o.Usage.IsSet() {
		return true
	}

	return false
}

// SetUsage gets a reference to the given NullableTokenUsage and assigns it to the Usage field.
func (o *RetainResponse) SetUsage(v TokenUsage) {
	o.Usage.Set(&v)
}
// SetUsageNil sets the value for Usage to be an explicit nil
func (o *RetainResponse) SetUsageNil() {
	o.Usage.Set(nil)
}

// UnsetUsage ensures that no value is present for Usage, not even an explicit nil
func (o *RetainResponse) UnsetUsage() {
	o.Usage.Unset()
}

func (o RetainResponse) MarshalJSON() ([]byte, error) {
	toSerialize,err := o.ToMap()
	if err != nil {
		return []byte{}, err
	}
	return json.Marshal(toSerialize)
}

func (o RetainResponse) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["success"] = o.Success
	toSerialize["bank_id"] = o.BankId
	toSerialize["items_count"] = o.ItemsCount
	toSerialize["async"] = o.Async
	if o.OperationId.IsSet() {
		toSerialize["operation_id"] = o.OperationId.Get()
	}
	if o.Usage.IsSet() {
		toSerialize["usage"] = o.Usage.Get()
	}
	return toSerialize, nil
}

func (o *RetainResponse) UnmarshalJSON(data []byte) (err error) {
	// This validates that all required properties are included in the JSON object
	// by unmarshalling the object into a generic map with string keys and checking
	// that every required field exists as a key in the generic map.
	requiredProperties := []string{
		"success",
		"bank_id",
		"items_count",
		"async",
	}

	allProperties := make(map[string]interface{})

	err = json.Unmarshal(data, &allProperties)

	if err != nil {
		return err;
	}

	for _, requiredProperty := range(requiredProperties) {
		if _, exists := allProperties[requiredProperty]; !exists {
			return fmt.Errorf("no value given for required property %v", requiredProperty)
		}
	}

	varRetainResponse := _RetainResponse{}

	decoder := json.NewDecoder(bytes.NewReader(data))
	decoder.DisallowUnknownFields()
	err = decoder.Decode(&varRetainResponse)

	if err != nil {
		return err
	}

	*o = RetainResponse(varRetainResponse)

	return err
}

type NullableRetainResponse struct {
	value *RetainResponse
	isSet bool
}

func (v NullableRetainResponse) Get() *RetainResponse {
	return v.value
}

func (v *NullableRetainResponse) Set(val *RetainResponse) {
	v.value = val
	v.isSet = true
}

func (v NullableRetainResponse) IsSet() bool {
	return v.isSet
}

func (v *NullableRetainResponse) Unset() {
	v.value = nil
	v.isSet = false
}

func NewNullableRetainResponse(val *RetainResponse) *NullableRetainResponse {
	return &NullableRetainResponse{value: val, isSet: true}
}

func (v NullableRetainResponse) MarshalJSON() ([]byte, error) {
	return json.Marshal(v.value)
}

func (v *NullableRetainResponse) UnmarshalJSON(src []byte) error {
	v.isSet = true
	return json.Unmarshal(src, &v.value)
}


