github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/libkb/contact_settings.go (about)

     1  package libkb
     2  
     3  import (
     4  	"github.com/keybase/client/go/protocol/keybase1"
     5  )
     6  
     7  type GetContactSettingsResponse struct {
     8  	AppStatusEmbed
     9  	Settings keybase1.ContactSettings `json:"settings"`
    10  }
    11  
    12  func GetContactSettings(mctx MetaContext) (ret keybase1.ContactSettings, err error) {
    13  	defer mctx.Trace("GetContactSettings", &err)()
    14  	apiArg := APIArg{
    15  		Endpoint:    "account/contact_settings",
    16  		SessionType: APISessionTypeREQUIRED,
    17  	}
    18  	var response GetContactSettingsResponse
    19  	err = mctx.G().API.GetDecode(mctx, apiArg, &response)
    20  	if err != nil {
    21  		return ret, err
    22  	}
    23  	ret = response.Settings
    24  	return ret, nil
    25  }
    26  
    27  func SetContactSettings(mctx MetaContext, arg keybase1.ContactSettings) (err error) {
    28  	defer mctx.Trace("SetContactSettings", &err)()
    29  	payload := make(JSONPayload)
    30  	payload["settings"] = arg
    31  	apiArg := APIArg{
    32  		Endpoint:    "account/contact_settings",
    33  		SessionType: APISessionTypeREQUIRED,
    34  		JSONPayload: payload,
    35  	}
    36  	_, err = mctx.G().API.Post(mctx, apiArg)
    37  	return err
    38  }