Class: LNURL

Inherits:
Base show all
Defined in:
lib/bitnob/objects/lnurl.rb

Instance Attribute Summary

Attributes inherited from Base

#production, #secret_key, #url

Instance Method Summary collapse

Methods inherited from Base

#base_url, #check_parameters, #get_request, #initialize, #post_request, #put_request

Constructor Details

This class inherits a constructor from Base

Instance Method Details

#create(data) ⇒ Object

Create Lightning URL & LN address

  • Required Function Parameters:

    data: {
          identifier: string,
          identifierType: string,
          customerEmail: string,
          tld: string,
          image: string   #jpg,png,svg url link
          description: string,
          satMinSendable: int
          satMaxSendable: int
          }
    


24
25
26
27
28
29
30
# File 'lib/bitnob/objects/lnurl.rb', line 24

def create(data)
    required_parameters = %w[identifier identifierType tld image customerEmail description satMinSendable satMaxSendable]

    checked_passed_parameters(required_parameters, data)
    payload = data.to_json
    post_request("#{base_url}#{BaseEndpoints::LNURL}", payload)
end

#decode_ln_address(data) ⇒ Object

DECODE LN ADDRESS

  • Required Function Parameters:

    data: {
    
          lnAddress: string,
          }
    


88
89
90
91
92
93
# File 'lib/bitnob/objects/lnurl.rb', line 88

def decode_ln_address(data)
    required_parameters = %w[lnAddress]
    checked_passed_parameters(required_parameters, data)
    payload = data.to_json
    post_request("#{base_url}#{BaseEndpoints::LNURL}/decodelnaddress", payload)
end

#decode_lnurl(encoded_ln_url) ⇒ Object

Decoding LN URL

  • Required Function Parameters:

    encoded_ln_url: string
    


36
37
38
39
# File 'lib/bitnob/objects/lnurl.rb', line 36

def decode_lnurl(encoded_ln_url)
    payload = {encodedLnUrl: encoded_ln_url}
    post_request("#{base_url}#{BaseEndpoints::LNURL}", payload.to_json)
end

#get_by_identifier(identifier) ⇒ Object

Get lnurl by identifier e.g email, username



120
121
122
# File 'lib/bitnob/objects/lnurl.rb', line 120

def get_by_identifier(identifier)
    get_request("#{base_url}#{BaseEndpoints::LNURL}/fetchlnurl/#{identifier}")
end

#get_id(id) ⇒ Object

Get lnurl by id



125
126
127
# File 'lib/bitnob/objects/lnurl.rb', line 125

def get_id(id)
    get_request("#{base_url}#{BaseEndpoints::LNURL}/#{id}")
end

#get_lnurlsObject

get all lnurls



115
116
117
# File 'lib/bitnob/objects/lnurl.rb', line 115

def get_lnurls()
    get_request("#{base_url}#{BaseEndpoints::LNURL}/")
end

#ln_withdrawal(data) ⇒ Object

CREATE LN WITHDRAWAL

  • Required Function Parameters:

    data: {
    
          customerEmail: string,
          satoshis: int,
          description: string,
          }
    


72
73
74
75
76
77
# File 'lib/bitnob/objects/lnurl.rb', line 72

def ln_withdrawal(data)
    required_parameters = %w[description customerEmail satoshis ]
    checked_passed_parameters(required_parameters, data)
    payload = data.to_json
    post_request("#{base_url}#{BaseEndpoints::LNURL}/createLnUrlWithdrawal", payload)
end

#pay_ln_address(data) ⇒ Object

PAY LIGHTNING ADDRESS

  • Required Function Parameters:

    data: {
          lnAddress: string,
          customerEmail: string,
          satoshis: int,
          reference: string
          }
    


107
108
109
110
111
112
# File 'lib/bitnob/objects/lnurl.rb', line 107

def pay_ln_address(data)
    required_parameters = %w[lnAddress customerEmail satoshis reference ]
    checked_passed_parameters(required_parameters, data)
    payload = data.to_json
    post_request("#{base_url}#{BaseEndpoints::LNURL}/paylnaddress", payload)
end

#pay_lnurl(data) ⇒ Object

PAY LNURL

  • Required Function Parameters:

    data: {
    
          encodedLnUrl: string,
          customerEmail: string,
          satoshis: int,
          reference: string,
          comment: string // optional 
          }
    


54
55
56
57
58
59
# File 'lib/bitnob/objects/lnurl.rb', line 54

def pay_lnurl(data)
    required_parameters = %w[encodedLnUrl customerEmail satoshis reference ]
    checked_passed_parameters(required_parameters, data)
    payload = data.to_json
    post_request("#{base_url}#{BaseEndpoints::LNURL}/paylnurl", payload)
end

#update_lnurl(id, data) ⇒ Object

PAY LNURL

  • Required Function Parameters:

    id, 
    data: {
          identifier: string,
          customerEmail: string,
          tld: string,
          image: string   #jpg,png,svg url link
          description: string,
          satMinSendable: int
          satMaxSendable: int
          }
    


143
144
145
146
147
# File 'lib/bitnob/objects/lnurl.rb', line 143

def update_lnurl(id, data)
    required_parameters = %w[identifier customerEmail tld image description satMinSendable satMinSendable ]
    checked_passed_parameters(required_parameters, data)
    put_request("#{base_url}#{BaseEndpoints::LNURL}/#{id}")
end