balanced 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/examples.rb +5 -5
- data/lib/balanced/resources/marketplace.rb +27 -21
- data/lib/balanced/version.rb +1 -1
- metadata +1 -1
data/examples/examples.rb
CHANGED
@@ -30,23 +30,23 @@ puts "create our marketplace"
|
|
30
30
|
begin
|
31
31
|
marketplace = Balanced::Marketplace.new.save
|
32
32
|
rescue Balanced::Conflict => ex
|
33
|
-
marketplace = Balanced::Marketplace.
|
33
|
+
marketplace = Balanced::Marketplace.mine
|
34
34
|
end
|
35
35
|
|
36
36
|
raise "Merchant.me should not be nil" if Balanced::Merchant.me.nil?
|
37
37
|
puts "what's my merchant?, easy: Merchant.me: ", Balanced::Merchant.me
|
38
38
|
|
39
39
|
# what's my marketplace?
|
40
|
-
raise "Marketplace.
|
41
|
-
puts "what's my marketplace?, easy: Marketplace.
|
40
|
+
raise "Marketplace.mine should not be nil" if Balanced::Marketplace.mine.nil?
|
41
|
+
puts "what's my marketplace?, easy: Marketplace.mine: ", Balanced::Marketplace.mine
|
42
42
|
|
43
43
|
puts "My marketplace's name is: #{marketplace.name}"
|
44
44
|
random_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
|
45
45
|
puts "Changing it to #{random_name}"
|
46
46
|
marketplace.name = random_name
|
47
47
|
marketplace.save
|
48
|
-
puts "My marketplace name is now: #{Balanced::Marketplace.
|
49
|
-
raise "Marketplace name is NOT #{random_name}!" if Balanced::Marketplace.
|
48
|
+
puts "My marketplace name is now: #{Balanced::Marketplace.mine.name}"
|
49
|
+
raise "Marketplace name is NOT #{random_name}!" if Balanced::Marketplace.mine.name != random_name
|
50
50
|
|
51
51
|
puts "cool! let's create a new card."
|
52
52
|
card = Balanced::Card.new(
|
@@ -6,30 +6,35 @@ module Balanced
|
|
6
6
|
|
7
7
|
@@marketplace_uri = nil
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
9
|
+
class << self
|
10
|
+
|
11
|
+
# Returns an instance representing the marketplace associated with
|
12
|
+
# the current API key.
|
13
|
+
#
|
14
|
+
# @return [Marketplace]
|
15
|
+
def my_marketplace
|
16
|
+
marketplace = Balanced::Merchant.me.marketplace
|
17
|
+
@@marketplace_uri = marketplace.uri if marketplace
|
18
|
+
marketplace
|
19
|
+
end
|
20
|
+
alias mine my_marketplace
|
21
|
+
|
22
|
+
# @return [String, nil] the marketplace's URI
|
23
|
+
def marketplace_uri
|
24
|
+
if !@@marketplace_uri and Balanced.is_configured_with_api_key?
|
25
|
+
begin
|
26
|
+
mine
|
27
|
+
rescue Balanced::Error
|
28
|
+
# do nothing..
|
29
|
+
end
|
26
30
|
end
|
31
|
+
@@marketplace_uri
|
32
|
+
end
|
33
|
+
|
34
|
+
def marketplace_exists?
|
35
|
+
!!marketplace_uri
|
27
36
|
end
|
28
|
-
@@marketplace_uri
|
29
|
-
end
|
30
37
|
|
31
|
-
def self.marketplace_exists?
|
32
|
-
!!marketplace_uri
|
33
38
|
end
|
34
39
|
|
35
40
|
# @return [Marketplace]
|
@@ -46,6 +51,7 @@ module Balanced
|
|
46
51
|
def my_marketplace
|
47
52
|
self.class.my_marketplace
|
48
53
|
end
|
54
|
+
alias mine my_marketplace
|
49
55
|
|
50
56
|
# Create an Account associated with this Marketplace. This account
|
51
57
|
# will have no roles associated with it.
|
data/lib/balanced/version.rb
CHANGED