github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/pkg/models/pulseprofile/pulseprofile.go (about)

     1  package pulseprofile
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/bitfinexcom/bitfinex-api-go/pkg/convert"
     7  )
     8  
     9  // PulseProfile data structure
    10  type PulseProfile struct {
    11  	ID            string
    12  	MTS           int64
    13  	Nickname      string
    14  	Picture       string
    15  	Text          string
    16  	TwitterHandle string
    17  	Followers     int64
    18  	Following     int64
    19  	TippingStatus int64
    20  }
    21  
    22  var pulseProfileFields = map[string]int{
    23  	"ID":  0,
    24  	"Mts": 1,
    25  	// "PLACEHOLDER": 2,
    26  	"Nickname": 3,
    27  	// "PLACEHOLDER": 4,
    28  	"Picture": 5,
    29  	"Text":    6,
    30  	// "PLACEHOLDER": 7,
    31  	// "PLACEHOLDER": 8,
    32  	"TwitterHandle": 9,
    33  	// "PLACEHOLDER": 10,
    34  	"Followers": 11,
    35  	"Following": 12,
    36  	// "PLACEHOLDER": 13,
    37  	// "PLACEHOLDER": 14,
    38  	// "PLACEHOLDER": 15,
    39  	"TippingStatus": 16,
    40  }
    41  
    42  // NewFromRaw takes in slice of interfaces and converts them to
    43  // pointer to Pulse Profile
    44  func NewFromRaw(raw []interface{}) (*PulseProfile, error) {
    45  	if len(raw) < 14 {
    46  		return nil, fmt.Errorf("data slice too short for PulseProfile: %#v", raw)
    47  	}
    48  
    49  	pp := &PulseProfile{}
    50  
    51  	pp.ID = convert.SValOrEmpty(raw[pulseProfileFields["ID"]])
    52  	pp.MTS = convert.I64ValOrZero(raw[pulseProfileFields["Mts"]])
    53  	pp.Nickname = convert.SValOrEmpty(raw[pulseProfileFields["Nickname"]])
    54  	pp.Picture = convert.SValOrEmpty(raw[pulseProfileFields["Picture"]])
    55  	pp.Text = convert.SValOrEmpty(raw[pulseProfileFields["Text"]])
    56  	pp.TwitterHandle = convert.SValOrEmpty(raw[pulseProfileFields["TwitterHandle"]])
    57  	pp.Followers = convert.I64ValOrZero(raw[pulseProfileFields["Followers"]])
    58  	pp.Following = convert.I64ValOrZero(raw[pulseProfileFields["Following"]])
    59  	pp.TippingStatus = convert.I64ValOrZero(raw[pulseProfileFields["TippingStatus"]])
    60  
    61  	return pp, nil
    62  }