Bitcoin Forum
July 07, 2024, 11:15:37 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitpay RubyGem  (Read 907 times)
phantastisch (OP)
Legendary
*
Offline Offline

Activity: 2270
Merit: 1363



View Profile
August 23, 2012, 09:36:48 PM
 #1

Hi Guys,

since i am learning Ruby i thought it would be cool to create a Ruby Gem for Bitpay.
You can create and request invoices from the Bitpay Api in an easy way.

Here it is :

https://github.com/phanaster/BP-for-Ruby

If you encounter any bugs, have advice, suggestions, or feedback of any kind, i would appreciate it.

Have fun !

Disclaimer : This is an Alpha Release. Keep this in mind, it probably can break or malfunction. Even if my tests did not show any bugs or misbehavior, its not perfect.

HOWEYCOINS   ▮      Excitement and         ⭐  ● TWITTER  ● FACEBOOK   ⭐       
  ▮    guaranteed returns                 ●TELEGRAM                         
  ▮  of the travel industry
    ⭐  ●Ann Thread ●Instagram   ⭐ 
✅    U.S.Sec    ➡️
✅  approved!  ➡️
davout
Legendary
*
Offline Offline

Activity: 1372
Merit: 1007


1davout


View Profile WWW
August 24, 2012, 09:02:57 AM
 #2

Why don't you just call it bitpay ?

phantastisch (OP)
Legendary
*
Offline Offline

Activity: 2270
Merit: 1363



View Profile
August 24, 2012, 09:08:16 AM
 #3

Why don't you just call it bitpay ?

I am bad at choosing names.  Cry

HOWEYCOINS   ▮      Excitement and         ⭐  ● TWITTER  ● FACEBOOK   ⭐       
  ▮    guaranteed returns                 ●TELEGRAM                         
  ▮  of the travel industry
    ⭐  ●Ann Thread ●Instagram   ⭐ 
✅    U.S.Sec    ➡️
✅  approved!  ➡️
Tachikoma
Hero Member
*****
Offline Offline

Activity: 938
Merit: 1000



View Profile WWW
August 24, 2012, 09:35:10 AM
 #4

Since you said you are learning ruby I would have some pointers.

1. Ruby uses camel-case for class names and underscores for variables and methods. Also try to use two spaces for tabs and use them consistently.
Code:
class BPLIB > class BpLib
bpCreateInvoice -> bp_create_invoice
etc.

You can read more about the Ruby style in this website.

2. You can make this a one liner if you would want to

Code:
options = @options.merge(options)
options[:price] = price
options[:orderId]= orderid
options[:posData]= posData

options = @options.merge(options).merge({:price => price, :orderId => orderid, :postDate => posData})

3. I would probably rewrite this bit using has_key? since I find it increases readability.

Code:
  postOptions.each_with_index do |opt,index|
    if options.include(opt[index])
      postdata[index] = options[index]
    end
  end

postOptions.each do |key|
  if @options.has_key?(key)
    postdata[key] = @options[key]
  end
end

4. Is the code actually working? It seems you define postdata after you try to fill it.

Hope these tips help Smiley

Electrum: the convenience of a web wallet, without the risks | Bytesized Seedboxes BTC/LTC supported
phantastisch (OP)
Legendary
*
Offline Offline

Activity: 2270
Merit: 1363



View Profile
August 24, 2012, 01:30:54 PM
 #5

Thank you for your nice feedback.  Smiley

I'm glad someone looked at it.

And yes it's working, the file you've been inspecting is an artifact i forgot in there.
I moved the stuff into the other file because i'm still figuring out method calls.

HOWEYCOINS   ▮      Excitement and         ⭐  ● TWITTER  ● FACEBOOK   ⭐       
  ▮    guaranteed returns                 ●TELEGRAM                         
  ▮  of the travel industry
    ⭐  ●Ann Thread ●Instagram   ⭐ 
✅    U.S.Sec    ➡️
✅  approved!  ➡️
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!