github.com/line/line-bot-sdk-go/v7@v7.21.0/linebot/sender.go (about)

     1  // Copyright 2020 LINE Corporation
     2  //
     3  // LINE Corporation licenses this file to you under the Apache License,
     4  // version 2.0 (the "License"); you may not use this file except in compliance
     5  // with the License. You may obtain a copy of the License at:
     6  //
     7  //   http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    11  // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    12  // License for the specific language governing permissions and limitations
    13  // under the License.
    14  
    15  package linebot
    16  
    17  import (
    18  	"encoding/json"
    19  )
    20  
    21  // Sender type
    22  type Sender struct {
    23  	Name    string
    24  	IconURL string
    25  }
    26  
    27  // MarshalJSON method of QuickReplyButton
    28  func (s *Sender) MarshalJSON() ([]byte, error) {
    29  	return json.Marshal(&struct {
    30  		Name    string `json:"name,omitempty"`
    31  		IconURL string `json:"iconUrl,omitempty"`
    32  	}{
    33  		Name:    s.Name,
    34  		IconURL: s.IconURL,
    35  	})
    36  }
    37  
    38  // NewSender function
    39  func NewSender(name, iconURL string) *Sender {
    40  	return &Sender{
    41  		Name:    name,
    42  		IconURL: iconURL,
    43  	}
    44  }