github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/session/create_dto.go (about)

     1  /*
     2   * Copyright (C) 2017 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 session
    19  
    20  import (
    21  	"encoding/json"
    22  
    23  	"github.com/mysteriumnetwork/node/identity"
    24  )
    25  
    26  var (
    27  	responseInvalidProposal    = CreateResponse{Success: false, Message: "Invalid Proposal"}
    28  	responseUnsupportedVersion = CreateResponse{Success: false, Message: "You are running and old version, please update your software"}
    29  	responseInternalError      = CreateResponse{Success: false, Message: "Internal Error"}
    30  )
    31  
    32  // CreateRequest structure represents message from service consumer to initiate session for given proposal id
    33  type CreateRequest struct {
    34  	ProposalID   int             `json:"proposal_id"`
    35  	Config       json.RawMessage `json:"config"`
    36  	ConsumerInfo *ConsumerInfo   `json:"consumer_info,omitempty"`
    37  }
    38  
    39  // ConsumerInfo represents the consumer related information
    40  type ConsumerInfo struct {
    41  	// TODO Should not use internal structures for transport
    42  	IssuerID       identity.Identity `json:"issuerID"`
    43  	HermesID       identity.Identity `json:"hermesID"`
    44  	PaymentVersion PaymentVersion    `json:"paymentVersion"`
    45  }
    46  
    47  // CreateResponse structure represents service provider response to given session request from consumer
    48  type CreateResponse struct {
    49  	Success     bool        `json:"success"`
    50  	Message     string      `json:"message"`
    51  	Session     SessionDto  `json:"session"`
    52  	PaymentInfo PaymentInfo `json:"paymentInfo"`
    53  }
    54  
    55  // SessionDto structure represents session information data within session creation response (session id and configuration options for underlying service type)
    56  type SessionDto struct {
    57  	ID     ID              `json:"id"`
    58  	Config json.RawMessage `json:"config"`
    59  }
    60  
    61  // PaymentInfo represents the payment version information
    62  type PaymentInfo struct {
    63  	Supports string `json:"supported"`
    64  }
    65  
    66  // PaymentVersion represents the different payment versions we have
    67  type PaymentVersion string
    68  
    69  // PaymentVersionV3 represents the new pingpong version
    70  const PaymentVersionV3 PaymentVersion = "v3"