github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/tequilapi/contract/mmn.go (about)

     1  /*
     2   * Copyright (C) 2020 The "MysteriumNetwork/node" Authors.
     3   *
     4   * This program is free software: you can redistribute it and/or modify
     5   * it under the terms of the GNU General Public License as published by
     6   * the Free Software Foundation, either version 3 of the License, or
     7   * (at your option) any later version.
     8   *
     9   * This program is distributed in the hope that it will be useful,
    10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12   * GNU General Public License for more details.
    13   *
    14   * You should have received a copy of the GNU General Public License
    15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16   */
    17  
    18  package contract
    19  
    20  import (
    21  	"github.com/mysteriumnetwork/go-rest/apierror"
    22  )
    23  
    24  // MMNApiKeyRequest request used to manage MMN's API key.
    25  // swagger:model MMNApiKeyRequest
    26  type MMNApiKeyRequest struct {
    27  	ApiKey string `json:"api_key"`
    28  }
    29  
    30  // Validate validates fields in request
    31  func (r MMNApiKeyRequest) Validate() *apierror.APIError {
    32  	v := apierror.NewValidator()
    33  	if len(r.ApiKey) == 0 {
    34  		v.Required("api_key")
    35  	} else if len(r.ApiKey) < 40 {
    36  		v.Invalid("api_key", "Should be at least 40 characters long")
    37  	}
    38  	return v.Err()
    39  }
    40  
    41  // MMNLinkRedirectResponse claim link response
    42  // swagger:model MMNLinkRedirectResponse
    43  type MMNLinkRedirectResponse struct {
    44  	Link string `json:"link"`
    45  }
    46  
    47  // MMNGrantVerificationResponse message received via redirect from mystnodes.com
    48  // swagger:model MMNGrantVerificationResponse
    49  type MMNGrantVerificationResponse struct {
    50  	ApiKey                        string `json:"api_key"`
    51  	WalletAddress                 string `json:"wallet_address"`
    52  	IsEligibleForFreeRegistration bool   `json:"is_eligible_for_free_registration"`
    53  }