/*
Hindsight HTTP API

HTTP API for Hindsight

API version: 0.5.3
*/

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

package hindsight

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

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

// MemoriesTimeseriesResponse Time-series of memory ingestion bucketed by time and fact type.
type MemoriesTimeseriesResponse struct {
	BankId string `json:"bank_id"`
	// One of: 1h, 12h, 1d, 7d, 30d, 90d.
	Period string `json:"period"`
	// Bucket granularity: minute, hour, day.
	Trunc string `json:"trunc"`
	// Per-bucket counts, always returned fully padded for the requested period.
	Buckets []MemoryTimeseriesBucket `json:"buckets,omitempty"`
}

type _MemoriesTimeseriesResponse MemoriesTimeseriesResponse

// NewMemoriesTimeseriesResponse instantiates a new MemoriesTimeseriesResponse 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 NewMemoriesTimeseriesResponse(bankId string, period string, trunc string) *MemoriesTimeseriesResponse {
	this := MemoriesTimeseriesResponse{}
	this.BankId = bankId
	this.Period = period
	this.Trunc = trunc
	return &this
}

// NewMemoriesTimeseriesResponseWithDefaults instantiates a new MemoriesTimeseriesResponse 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 NewMemoriesTimeseriesResponseWithDefaults() *MemoriesTimeseriesResponse {
	this := MemoriesTimeseriesResponse{}
	return &this
}

// GetBankId returns the BankId field value
func (o *MemoriesTimeseriesResponse) 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 *MemoriesTimeseriesResponse) GetBankIdOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.BankId, true
}

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

// GetPeriod returns the Period field value
func (o *MemoriesTimeseriesResponse) GetPeriod() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Period
}

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

// SetPeriod sets field value
func (o *MemoriesTimeseriesResponse) SetPeriod(v string) {
	o.Period = v
}

// GetTrunc returns the Trunc field value
func (o *MemoriesTimeseriesResponse) GetTrunc() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Trunc
}

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

// SetTrunc sets field value
func (o *MemoriesTimeseriesResponse) SetTrunc(v string) {
	o.Trunc = v
}

// GetBuckets returns the Buckets field value if set, zero value otherwise.
func (o *MemoriesTimeseriesResponse) GetBuckets() []MemoryTimeseriesBucket {
	if o == nil || IsNil(o.Buckets) {
		var ret []MemoryTimeseriesBucket
		return ret
	}
	return o.Buckets
}

// GetBucketsOk returns a tuple with the Buckets field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *MemoriesTimeseriesResponse) GetBucketsOk() ([]MemoryTimeseriesBucket, bool) {
	if o == nil || IsNil(o.Buckets) {
		return nil, false
	}
	return o.Buckets, true
}

// HasBuckets returns a boolean if a field has been set.
func (o *MemoriesTimeseriesResponse) HasBuckets() bool {
	if o != nil && !IsNil(o.Buckets) {
		return true
	}

	return false
}

// SetBuckets gets a reference to the given []MemoryTimeseriesBucket and assigns it to the Buckets field.
func (o *MemoriesTimeseriesResponse) SetBuckets(v []MemoryTimeseriesBucket) {
	o.Buckets = v
}

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

func (o MemoriesTimeseriesResponse) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["bank_id"] = o.BankId
	toSerialize["period"] = o.Period
	toSerialize["trunc"] = o.Trunc
	if !IsNil(o.Buckets) {
		toSerialize["buckets"] = o.Buckets
	}
	return toSerialize, nil
}

func (o *MemoriesTimeseriesResponse) 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{
		"bank_id",
		"period",
		"trunc",
	}

	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)
		}
	}

	varMemoriesTimeseriesResponse := _MemoriesTimeseriesResponse{}

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

	if err != nil {
		return err
	}

	*o = MemoriesTimeseriesResponse(varMemoriesTimeseriesResponse)

	return err
}

type NullableMemoriesTimeseriesResponse struct {
	value *MemoriesTimeseriesResponse
	isSet bool
}

func (v NullableMemoriesTimeseriesResponse) Get() *MemoriesTimeseriesResponse {
	return v.value
}

func (v *NullableMemoriesTimeseriesResponse) Set(val *MemoriesTimeseriesResponse) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableMemoriesTimeseriesResponse(val *MemoriesTimeseriesResponse) *NullableMemoriesTimeseriesResponse {
	return &NullableMemoriesTimeseriesResponse{value: val, isSet: true}
}

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

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


