fb_graph 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -13,6 +13,10 @@ tmtags
13
13
  ## VIM
14
14
  *.swp
15
15
 
16
+
17
+ ## RVM
18
+ .rvmrc
19
+
16
20
  ## PROJECT::GENERAL
17
21
  coverage
18
22
  rdoc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fb_graph (2.0.0)
4
+ fb_graph (2.0.1)
5
5
  httpclient (>= 2.2.0.2)
6
6
  rack-oauth2 (>= 0.8.0)
7
7
 
@@ -37,6 +37,7 @@ GEM
37
37
  jruby-openssl (0.7.4)
38
38
  bouncy-castle-java
39
39
  json (1.5.3)
40
+ json (1.5.3-java)
40
41
  rack (1.2.3)
41
42
  rack-mount (0.6.14)
42
43
  rack (>= 1.0.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.0.2
@@ -0,0 +1,13 @@
1
+ module FbGraph
2
+ class AdAccount < Node
3
+ attr_accessor :account_id, :name, :account_status, :daily_spend_limit, :users, :currency, :timezone_id, :timezone_name, :capabilities, :account_groups
4
+
5
+ def initialize(identifier, attributes = {})
6
+ super
7
+
8
+ %w(account_id name account_status daily_spend_limit currency timezone_id timezone_name).each do |field|
9
+ send("#{field}=", attributes[field.to_sym])
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ module FbGraph
2
+ class AdCampaign < Node
3
+ attr_accessor :campaign_id, :account_id, :name, :start_time, :end_time, :daily_budget, :campaign_status, :lifetime_budget
4
+
5
+ def initialize(identifier, attributes = {})
6
+ super
7
+
8
+ %w(campaign_id account_id name daily_budget campaign_status lifetime_budget).each do |field|
9
+ send("#{field}=", attributes[field.to_sym])
10
+ end
11
+
12
+ %w(start_time end_time).each do |field|
13
+ send("#{field}=", Time.parse(attributes[field.to_sym]).utc) if attributes[field.to_sym]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -24,7 +24,7 @@ module FbGraph
24
24
  @start_time = case start_time
25
25
  when String
26
26
  Time.parse(start_time)
27
- when Fixnum
27
+ when Integer
28
28
  Time.at(start_time)
29
29
  end
30
30
  end
@@ -32,7 +32,7 @@ module FbGraph
32
32
  @end_time = case end_time
33
33
  when String
34
34
  Time.parse(end_time)
35
- when Fixnum
35
+ when Integer
36
36
  Time.at(end_time)
37
37
  end
38
38
  end
@@ -13,6 +13,7 @@ module FbGraph
13
13
  if to = attributes[:to]
14
14
  @to = User.new(to[:id], to)
15
15
  end
16
+ @amount = attributes[:amount]
16
17
  @status = attributes[:status]
17
18
  @country = attributes[:country]
18
19
  if attributes[:created_time]
@@ -23,22 +24,25 @@ module FbGraph
23
24
  end
24
25
  end
25
26
 
26
- def settled!(options = {})
27
+ def settle!(options = {})
27
28
  update options.merge(:status => :settled)
28
29
  end
30
+ alias_method :settled!, :settle!
29
31
 
30
- def refunded!(options = {})
32
+ def refund!(options = {})
31
33
  update options.merge(:status => :refunded)
32
34
  end
35
+ alias_method :refunded!, :refund!
33
36
 
34
- def canceled!(options = {})
37
+ def cancel!(options = {})
35
38
  update options.merge(:status => :canceled)
36
39
  end
40
+ alias_method :canceled!, :cancel!
37
41
 
38
42
  def update(attributes = {})
39
43
  _attributes_ = attributes.dup
40
44
  params = {
41
- :access_token => self.access_token,
45
+ :access_token => _attributes_.delete(:access_token) || self.access_token,
42
46
  :status => _attributes_.delete(:status),
43
47
  :message => _attributes_.delete(:message),
44
48
  :refund_funding_source => _attributes_.delete(:refund_funding_source),
data/lib/fb_graph.rb CHANGED
@@ -87,6 +87,9 @@ require 'fb_graph/user'
87
87
  require 'fb_graph/test_user' # Load after FbGraph::User
88
88
  require 'fb_graph/video'
89
89
 
90
+ require 'fb_graph/adaccount'
91
+ require 'fb_graph/adcampaign'
92
+
90
93
  require 'fb_graph/klass'
91
94
  require 'fb_graph/project'
92
95
 
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe FbGraph::AdAccount, '.new' do
4
+ it 'should setup all supported attributes' do
5
+ attributes = {
6
+ :id => 'act_12345566',
7
+ :account_id => 12345566,
8
+ :name => 'Test Ad Account',
9
+ :account_status => 1,
10
+ :daily_spend_limit => 20000,
11
+ :currency => "USD",
12
+ :timezone_id => 1,
13
+ :timezone_name => "America/Los_Angeles"
14
+ }
15
+ ad_account = FbGraph::AdAccount.new(attributes.delete(:id), attributes)
16
+ ad_account.identifier.should == "act_12345566"
17
+ ad_account.account_id.should == 12345566
18
+ ad_account.name.should == "Test Ad Account"
19
+ ad_account.account_status.should == 1
20
+ ad_account.daily_spend_limit.should == 20000
21
+ ad_account.currency.should == "USD"
22
+ ad_account.timezone_id.should == 1
23
+ ad_account.timezone_name.should == "America/Los_Angeles"
24
+ end
25
+ end
26
+
27
+
28
+ describe FbGraph::AdAccount, '.fetch' do
29
+ it 'should get the ad account' do
30
+ mock_graph :get, 'act_12345566', 'adaccounts/test_ad_account', :access_token => 'access_token' do
31
+ ad_account = FbGraph::AdAccount.fetch('act_12345566', :access_token => 'access_token')
32
+
33
+ ad_account.identifier.should == "act_12345566"
34
+ ad_account.account_id.should == 12345566
35
+ ad_account.name.should == "Test Ad Account"
36
+ ad_account.account_status.should == 1
37
+ ad_account.daily_spend_limit.should == 20000
38
+ ad_account.currency.should == "USD"
39
+ ad_account.timezone_id.should == 1
40
+ ad_account.timezone_name.should == "America/Los_Angeles"
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe FbGraph::AdCampaign, '.new' do
4
+ it 'should setup all supported attributes' do
5
+ attributes = {
6
+ :id => '6003266501234',
7
+ :campaign_id => 6003266501234,
8
+ :account_id => 12345566,
9
+ :name => "Test Ad Campaign",
10
+ :start_time => "2011-07-01T12:00:00+00:00",
11
+ :end_time => "2011-07-14T16:00:00+00:00",
12
+ :daily_budget => 20000,
13
+ :campaign_status => 1,
14
+ :lifetime_budget => 100000
15
+ }
16
+ ad_campaign = FbGraph::AdCampaign.new(attributes.delete(:id), attributes)
17
+ ad_campaign.identifier.should == "6003266501234"
18
+ ad_campaign.account_id.should == 12345566
19
+ ad_campaign.name.should == "Test Ad Campaign"
20
+ ad_campaign.start_time.should == Time.parse("2011-07-01T12:00:00Z")
21
+ ad_campaign.end_time.should == Time.parse("2011-07-14T16:00:00Z")
22
+ ad_campaign.daily_budget.should == 20000
23
+ ad_campaign.campaign_status.should == 1
24
+ ad_campaign.lifetime_budget.should == 100000
25
+ end
26
+ end
27
+
28
+
29
+ describe FbGraph::AdCampaign, '.fetch' do
30
+ it 'should get the ad campaign' do
31
+ mock_graph :get, '16003266501234', 'adcampaigns/test_ad_campaign', :access_token => 'access_token' do
32
+ ad_campaign = FbGraph::AdCampaign.fetch('16003266501234', :access_token => 'access_token')
33
+
34
+ ad_campaign.identifier.should == "6003266501234"
35
+ ad_campaign.account_id.should == 12345566
36
+ ad_campaign.name.should == "Test Ad Campaign"
37
+ ad_campaign.start_time.should == Time.parse("2011-07-01T12:00:00Z")
38
+ ad_campaign.end_time.should == Time.parse("2011-07-14T16:00:00Z")
39
+ ad_campaign.daily_budget.should == 20000
40
+ ad_campaign.campaign_status.should == 1
41
+ ad_campaign.lifetime_budget.should == 100000
42
+ end
43
+ end
44
+ end
@@ -1,19 +1,66 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Order do
4
- describe '#new' do
5
- it :TODO
4
+ subject { order }
5
+ let(:order) { FbGraph::Order.new attributes[:id], attributes }
6
+ let :attributes do
7
+ {
8
+ :id => '9005539514450',
9
+ :from => {
10
+ :name => 'Nov Matake',
11
+ :id => '579612276'
12
+ },
13
+ :to => {
14
+ :name => 'Nov Matake',
15
+ :id => '579612276'
16
+ },
17
+ :amount => 2,
18
+ :status => 'settled',
19
+ :application => {
20
+ :name => 'gem sample',
21
+ :id => '134145643294322'
22
+ },
23
+ :created_time => '2011-09-01T04:34:35+0000',
24
+ :updated_time => '2011-09-01T04:34:38+0000'
25
+ }
6
26
  end
7
27
 
8
- describe '#settled!' do
9
- it :TODO
28
+ its(:identifier) { should == '9005539514450' }
29
+ its(:from) { should == FbGraph::User.new('579612276', :name => 'Nov Matake') }
30
+ its(:to) { should == FbGraph::User.new('579612276', :name => 'Nov Matake') }
31
+ its(:application) { should == FbGraph::Application.new('134145643294322', :name => 'gem sample') }
32
+ its(:amount) { should == 2 }
33
+ its(:status) { should == 'settled' }
34
+ its(:created_time) { should == Time.parse('2011-09-01T04:34:35+0000') }
35
+ its(:updated_time) { should == Time.parse('2011-09-01T04:34:38+0000') }
36
+
37
+ describe '#settle!' do
38
+ it do
39
+ expect { order.settle! }.should request_to order.identifier, :post
40
+ end
41
+
42
+ it 'I have never succeeded this call yet'
10
43
  end
11
44
 
12
- describe '#refunded!' do
13
- it :TODO
45
+ describe '#refund!' do
46
+ it do
47
+ expect { order.refund! }.should request_to order.identifier, :post
48
+ end
49
+
50
+ it 'should return true' do
51
+ mock_graph :post, order.identifier, 'true', :access_token => 'access_token', :params => {
52
+ :status => 'refunded'
53
+ } do
54
+ order.refunded!(:access_token => 'access_token').should be_true
55
+ end
56
+ end
14
57
  end
15
58
 
16
- describe '#canceled' do
17
- it :TODO
59
+ describe '#cancel!' do
60
+ it do
61
+ expect { order.cancel! }.should request_to order.identifier, :post
62
+ end
63
+
64
+ it 'I have never succeeded this call yet'
18
65
  end
19
66
  end
@@ -0,0 +1,10 @@
1
+ {
2
+ "id": "act_12345566",
3
+ "account_id": 12345566,
4
+ "name": "Test Ad Account",
5
+ "account_status": 1,
6
+ "daily_spend_limit": 20000,
7
+ "currency": "USD",
8
+ "timezone_id": 1,
9
+ "timezone_name": "America/Los_Angeles"
10
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "id": "6003266501234",
3
+ "campaign_id": 6003266501234,
4
+ "account_id": 12345566,
5
+ "name": "Test Ad Campaign",
6
+ "start_time": "2011-07-01T12:00:00+00:00",
7
+ "end_time": "2011-07-14T16:00:00+00:00",
8
+ "daily_budget": 20000,
9
+ "campaign_status": 1,
10
+ "lifetime_budget": 100000
11
+ }
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 11
4
5
  prerelease:
5
- version: 2.0.1
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 2
10
+ version: 2.0.2
6
11
  platform: ruby
7
12
  authors:
8
13
  - nov matake
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-08-24 00:00:00 Z
18
+ date: 2011-09-01 00:00:00 Z
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: httpclient
@@ -20,6 +25,12 @@ dependencies:
20
25
  requirements:
21
26
  - - ">="
22
27
  - !ruby/object:Gem::Version
28
+ hash: 123
29
+ segments:
30
+ - 2
31
+ - 2
32
+ - 0
33
+ - 2
23
34
  version: 2.2.0.2
24
35
  type: :runtime
25
36
  version_requirements: *id001
@@ -31,6 +42,11 @@ dependencies:
31
42
  requirements:
32
43
  - - ">="
33
44
  - !ruby/object:Gem::Version
45
+ hash: 63
46
+ segments:
47
+ - 0
48
+ - 8
49
+ - 0
34
50
  version: 0.8.0
35
51
  type: :runtime
36
52
  version_requirements: *id002
@@ -42,6 +58,10 @@ dependencies:
42
58
  requirements:
43
59
  - - ">="
44
60
  - !ruby/object:Gem::Version
61
+ hash: 27
62
+ segments:
63
+ - 0
64
+ - 8
45
65
  version: "0.8"
46
66
  type: :development
47
67
  version_requirements: *id003
@@ -53,6 +73,10 @@ dependencies:
53
73
  requirements:
54
74
  - - ">="
55
75
  - !ruby/object:Gem::Version
76
+ hash: 25
77
+ segments:
78
+ - 0
79
+ - 9
56
80
  version: "0.9"
57
81
  type: :development
58
82
  version_requirements: *id004
@@ -64,6 +88,9 @@ dependencies:
64
88
  requirements:
65
89
  - - ">="
66
90
  - !ruby/object:Gem::Version
91
+ hash: 7
92
+ segments:
93
+ - 2
67
94
  version: "2"
68
95
  type: :development
69
96
  version_requirements: *id005
@@ -75,6 +102,11 @@ dependencies:
75
102
  requirements:
76
103
  - - ">="
77
104
  - !ruby/object:Gem::Version
105
+ hash: 11
106
+ segments:
107
+ - 1
108
+ - 6
109
+ - 2
78
110
  version: 1.6.2
79
111
  type: :development
80
112
  version_requirements: *id006
@@ -86,6 +118,11 @@ dependencies:
86
118
  requirements:
87
119
  - - ">="
88
120
  - !ruby/object:Gem::Version
121
+ hash: 11
122
+ segments:
123
+ - 3
124
+ - 0
125
+ - 6
89
126
  version: 3.0.6
90
127
  type: :development
91
128
  version_requirements: *id007
@@ -113,6 +150,8 @@ files:
113
150
  - fb_graph.gemspec
114
151
  - lib/fb_graph.rb
115
152
  - lib/fb_graph/action.rb
153
+ - lib/fb_graph/adaccount.rb
154
+ - lib/fb_graph/adcampaign.rb
116
155
  - lib/fb_graph/album.rb
117
156
  - lib/fb_graph/app_request.rb
118
157
  - lib/fb_graph/application.rb
@@ -217,6 +256,8 @@ files:
217
256
  - lib/fb_graph/video.rb
218
257
  - lib/fb_graph/work.rb
219
258
  - lib/patch/rack/oauth2/util.rb
259
+ - spec/fb_graph/adaccount_spec.rb
260
+ - spec/fb_graph/adcampaign_spec.rb
220
261
  - spec/fb_graph/album_spec.rb
221
262
  - spec/fb_graph/app_request_spec.rb
222
263
  - spec/fb_graph/application_spec.rb
@@ -319,6 +360,8 @@ files:
319
360
  - spec/fb_graph/video_spec.rb
320
361
  - spec/fb_graph/work_spec.rb
321
362
  - spec/helpers/webmock_helper.rb
363
+ - spec/mock_json/adaccounts/test_ad_account.json
364
+ - spec/mock_json/adcampaigns/test_ad_campaign.json
322
365
  - spec/mock_json/albums/photos/matake_private.json
323
366
  - spec/mock_json/albums/photos/post_with_valid_access_token.json
324
367
  - spec/mock_json/applications/accounts/private.json
@@ -471,12 +514,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
471
514
  requirements:
472
515
  - - ">="
473
516
  - !ruby/object:Gem::Version
517
+ hash: 3
518
+ segments:
519
+ - 0
474
520
  version: "0"
475
521
  required_rubygems_version: !ruby/object:Gem::Requirement
476
522
  none: false
477
523
  requirements:
478
524
  - - ">="
479
525
  - !ruby/object:Gem::Version
526
+ hash: 3
527
+ segments:
528
+ - 0
480
529
  version: "0"
481
530
  requirements: []
482
531
 
@@ -486,6 +535,8 @@ signing_key:
486
535
  specification_version: 3
487
536
  summary: A full-stack Facebook Graph API wrapper in Ruby.
488
537
  test_files:
538
+ - spec/fb_graph/adaccount_spec.rb
539
+ - spec/fb_graph/adcampaign_spec.rb
489
540
  - spec/fb_graph/album_spec.rb
490
541
  - spec/fb_graph/app_request_spec.rb
491
542
  - spec/fb_graph/application_spec.rb
@@ -588,6 +639,8 @@ test_files:
588
639
  - spec/fb_graph/video_spec.rb
589
640
  - spec/fb_graph/work_spec.rb
590
641
  - spec/helpers/webmock_helper.rb
642
+ - spec/mock_json/adaccounts/test_ad_account.json
643
+ - spec/mock_json/adcampaigns/test_ad_campaign.json
591
644
  - spec/mock_json/albums/photos/matake_private.json
592
645
  - spec/mock_json/albums/photos/post_with_valid_access_token.json
593
646
  - spec/mock_json/applications/accounts/private.json