Class: BraintreeAccount

Inherits:
Object
  • Object
show all
Defined in:
lib/braintree_account.rb

Constant Summary collapse

RequiredOptions =
[:environment, :merchant_id, :public_key, :private_key]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ BraintreeAccount

Returns a new instance of BraintreeAccount.



7
8
9
10
11
12
13
# File 'lib/braintree_account.rb', line 7

def initialize(options)
  @masked = false
  @environment = options[:environment]
  @merchant_id = options[:merchant_id]
  @public_key = options[:public_key]
  @private_key = options[:private_key]
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



2
3
4
# File 'lib/braintree_account.rb', line 2

def environment
  @environment
end

#maskedObject

Returns the value of attribute masked.



3
4
5
# File 'lib/braintree_account.rb', line 3

def masked
  @masked
end

#merchant_idObject (readonly)

Returns the value of attribute merchant_id.



2
3
4
# File 'lib/braintree_account.rb', line 2

def merchant_id
  @merchant_id
end

#private_keyObject (readonly)

Returns the value of attribute private_key.



2
3
4
# File 'lib/braintree_account.rb', line 2

def private_key
  @private_key
end

#public_keyObject (readonly)

Returns the value of attribute public_key.



2
3
4
# File 'lib/braintree_account.rb', line 2

def public_key
  @public_key
end

Instance Method Details

#_display(string) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/braintree_account.rb', line 30

def _display(string)
  if @masked
    if string.length > 4
      string[0..3] + "*" * (string.length - 4)
    else
      "*"*string.length
    end
  else
    string
  end
end

#activate!Object



15
16
17
18
19
20
21
# File 'lib/braintree_account.rb', line 15

def activate!
  Braintree::Configuration.environment = @environment.to_sym
  Braintree::Configuration.merchant_id = @merchant_id
  Braintree::Configuration.public_key  = @public_key
  Braintree::Configuration.private_key = @private_key
  Braintree::Configuration.logger = Logger.new("/dev/null")
end

#as_jsonObject



23
24
25
26
27
28
# File 'lib/braintree_account.rb', line 23

def as_json
  {
    :environment => @environment,
    :merchant_id => @merchant_id,
  }
end