fb_graph 2.5.6 → 2.5.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fb_graph (2.5.6)
4
+ fb_graph (2.5.7)
5
5
  httpclient (>= 2.2.0.2)
6
6
  json
7
7
  rack-oauth2 (>= 0.14.4)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.5.6
1
+ 2.5.7
@@ -9,12 +9,37 @@ module FbGraph
9
9
  include Connections::AdConnectionObjects
10
10
  include Connections::AdPreviews
11
11
 
12
- attr_accessor :account_id, :name, :account_status, :daily_spend_limit, :users, :currency, :timezone_id, :timezone_name, :capabilities, :account_groups
12
+ ATTRS = [
13
+ :account_id,
14
+ :name,
15
+ :account_status,
16
+ :daily_spend_limit,
17
+ :users,
18
+ :currency,
19
+ :timezone_id,
20
+ :timezone_name,
21
+ :capabilities,
22
+ :account_groups,
23
+ :is_personal,
24
+ :business_name,
25
+ :business_street,
26
+ :business_street2,
27
+ :business_city,
28
+ :business_state,
29
+ :business_zip,
30
+ :business_country_code,
31
+ :vat_status,
32
+ :agency_client_declaration,
33
+ :spend_cap,
34
+ :amount_spent
35
+ ]
36
+
37
+ attr_accessor *ATTRS
13
38
 
14
39
  def initialize(identifier, attributes = {})
15
40
  super
16
41
 
17
- %w(account_id name account_status daily_spend_limit users currency timezone_id timezone_name).each do |field|
42
+ ATTRS.each do |field|
18
43
  send("#{field}=", attributes[field.to_sym])
19
44
  end
20
45
 
@@ -5,7 +5,6 @@ module FbGraph
5
5
  posts = self.connection :feed, options
6
6
  posts.map! do |post|
7
7
  Post.new post[:id], post.merge(
8
- :context => self.class,
9
8
  :access_token => options[:access_token] || self.access_token
10
9
  )
11
10
  end
data/lib/fb_graph/node.rb CHANGED
@@ -135,16 +135,11 @@ module FbGraph
135
135
  when 'null'
136
136
  nil
137
137
  else
138
- if response.body.gsub('"', '').to_i.to_s == response.body.gsub('"', '')
139
- # NOTE: User#app_request! returns ID as a JSON string not as a JSON object..
140
- response.body.gsub('"', '')
138
+ _response_ = JSON.parse(response.body).with_indifferent_access
139
+ if (200...300).include?(response.status)
140
+ _response_
141
141
  else
142
- _response_ = JSON.parse(response.body).with_indifferent_access
143
- if (200...300).include?(response.status)
144
- _response_
145
- else
146
- Exception.handle_httpclient_error(_response_, response.headers)
147
- end
142
+ Exception.handle_httpclient_error(_response_, response.headers)
148
143
  end
149
144
  end
150
145
  rescue JSON::ParserError
@@ -2,11 +2,13 @@ module FbGraph
2
2
  class Picture
3
3
  include Comparison
4
4
 
5
- attr_accessor :is_silhouette, :url
5
+ @@attributes = [:is_silhouette, :url, :height, :width]
6
+ attr_accessor *@@attributes
6
7
 
7
8
  def initialize(attributes = {})
8
- @is_silhouette = attributes[:is_silhouette]
9
- @url = attributes[:url]
9
+ @@attributes.each do |key|
10
+ self.send :"#{key}=", attributes[key]
11
+ end
10
12
  end
11
13
  end
12
14
  end
data/lib/fb_graph/post.rb CHANGED
@@ -27,11 +27,7 @@ module FbGraph
27
27
  elsif to[:version]
28
28
  Group.new(to[:id], to)
29
29
  else
30
- if attributes[:context] == Application
31
- Application.new(to[:id], to)
32
- else
33
- User.new(to[:id], to)
34
- end
30
+ User.new(to[:id], to)
35
31
  end
36
32
  end
37
33
  end
@@ -10,7 +10,34 @@ describe FbGraph::AdAccount, '.new' do
10
10
  :daily_spend_limit => 20000,
11
11
  :currency => "USD",
12
12
  :timezone_id => 1,
13
- :timezone_name => "America/Los_Angeles"
13
+ :timezone_name => "America/Los_Angeles",
14
+ :capabilities => [1,2,3],
15
+ :account_groups =>[{"account_group_id"=>12344321, "name"=>"Account Group", "status"=>1}],
16
+ :is_personal => 1,
17
+ :business_name => "Business Inc.",
18
+ :business_street => "123 Fake St.",
19
+ :business_street2 => "Apt. 2B",
20
+ :business_city => "New York",
21
+ :business_state => "Alabama",
22
+ :business_zip => "33333",
23
+ :business_country_code => "US",
24
+ :vat_status => 1,
25
+ :agency_client_declaration => {
26
+ "agency_representing_client"=>1,
27
+ "client_based_in_france"=>0,
28
+ "has_written_mandate_from_advertiser"=>1,
29
+ "is_client_paying_invoices"=>1,
30
+ "client_name"=>"Client Smith",
31
+ "client_email_address"=>"fake@example.com",
32
+ "client_street" => "321 Real St.",
33
+ "client_street2" => "Suite 123",
34
+ "client_city" => "Los Angeles",
35
+ "client_province" => "AB",
36
+ "client_postal_code" => "33433",
37
+ "client_country_code" => "CA"
38
+ },
39
+ :spend_cap => 1500,
40
+ :amount_spent => 1499
14
41
  }
15
42
  ad_account = FbGraph::AdAccount.new(attributes.delete(:id), attributes)
16
43
  ad_account.identifier.should == "act_12345566"
@@ -21,6 +48,33 @@ describe FbGraph::AdAccount, '.new' do
21
48
  ad_account.currency.should == "USD"
22
49
  ad_account.timezone_id.should == 1
23
50
  ad_account.timezone_name.should == "America/Los_Angeles"
51
+ ad_account.capabilities.should == [1,2,3]
52
+ ad_account.account_groups.should == [{"account_group_id"=>12344321, "name"=>"Account Group", "status"=>1}]
53
+ ad_account.is_personal.should == 1
54
+ ad_account.business_name.should == "Business Inc."
55
+ ad_account.business_street.should == "123 Fake St."
56
+ ad_account.business_street2.should == "Apt. 2B"
57
+ ad_account.business_city.should == "New York"
58
+ ad_account.business_state.should == "Alabama"
59
+ ad_account.business_zip.should == "33333"
60
+ ad_account.business_country_code.should == "US"
61
+ ad_account.vat_status.should == 1
62
+ ad_account.agency_client_declaration.should == {
63
+ "agency_representing_client"=>1,
64
+ "client_based_in_france"=>0,
65
+ "has_written_mandate_from_advertiser"=>1,
66
+ "is_client_paying_invoices"=>1,
67
+ "client_name"=>"Client Smith",
68
+ "client_email_address"=>"fake@example.com",
69
+ "client_street" => "321 Real St.",
70
+ "client_street2" => "Suite 123",
71
+ "client_city" => "Los Angeles",
72
+ "client_province" => "AB",
73
+ "client_postal_code" => "33433",
74
+ "client_country_code" => "CA"
75
+ }
76
+ ad_account.spend_cap.should == 1500
77
+ ad_account.amount_spent.should == 1499
24
78
  end
25
79
  end
26
80
 
@@ -38,6 +92,33 @@ describe FbGraph::AdAccount, '.fetch' do
38
92
  ad_account.currency.should == "USD"
39
93
  ad_account.timezone_id.should == 1
40
94
  ad_account.timezone_name.should == "America/Los_Angeles"
95
+ ad_account.capabilities.should == [1,2,3]
96
+ ad_account.account_groups.should == [{"account_group_id"=>12344321, "name"=>"Account Group", "status"=>1}]
97
+ ad_account.is_personal.should == 1
98
+ ad_account.business_name.should == "Business Inc."
99
+ ad_account.business_street.should == "123 Fake St."
100
+ ad_account.business_street2.should == "Apt. 2B"
101
+ ad_account.business_city.should == "New York"
102
+ ad_account.business_state.should == "Alabama"
103
+ ad_account.business_zip.should == "33333"
104
+ ad_account.business_country_code.should == "US"
105
+ ad_account.vat_status.should == 1
106
+ ad_account.agency_client_declaration.should == {
107
+ "agency_representing_client"=>1,
108
+ "client_based_in_france"=>0,
109
+ "has_written_mandate_from_advertiser"=>1,
110
+ "is_client_paying_invoices"=>1,
111
+ "client_name"=>"Client Smith",
112
+ "client_email_address"=>"fake@example.com",
113
+ "client_street" => "321 Real St.",
114
+ "client_street2" => "Suite 123",
115
+ "client_city" => "Los Angeles",
116
+ "client_province" => "AB",
117
+ "client_postal_code" => "33433",
118
+ "client_country_code" => "CA"
119
+ }
120
+ ad_account.spend_cap.should == 1500
121
+ ad_account.amount_spent.should == 1499
41
122
  end
42
123
  end
43
124
  end
@@ -6,5 +6,32 @@
6
6
  "daily_spend_limit": 20000,
7
7
  "currency": "USD",
8
8
  "timezone_id": 1,
9
- "timezone_name": "America/Los_Angeles"
9
+ "timezone_name": "America/Los_Angeles",
10
+ "capabilities": [1,2,3],
11
+ "account_groups": [{"account_group_id":12344321, "name":"Account Group", "status":1}],
12
+ "is_personal": 1,
13
+ "business_name": "Business Inc.",
14
+ "business_street": "123 Fake St.",
15
+ "business_street2": "Apt. 2B",
16
+ "business_city": "New York",
17
+ "business_state": "Alabama",
18
+ "business_zip": "33333",
19
+ "business_country_code": "US",
20
+ "vat_status": 1,
21
+ "agency_client_declaration": {
22
+ "agency_representing_client":1,
23
+ "client_based_in_france":0,
24
+ "has_written_mandate_from_advertiser":1,
25
+ "is_client_paying_invoices":1,
26
+ "client_name":"Client Smith",
27
+ "client_email_address":"fake@example.com",
28
+ "client_street": "321 Real St.",
29
+ "client_street2": "Suite 123",
30
+ "client_city": "Los Angeles",
31
+ "client_province": "AB",
32
+ "client_postal_code": "33433",
33
+ "client_country_code": "CA"
34
+ },
35
+ "spend_cap": 1500,
36
+ "amount_spent": 1499
10
37
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.6
4
+ version: 2.5.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-01 00:00:00.000000000 Z
12
+ date: 2012-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient
@@ -725,7 +725,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
725
725
  version: '0'
726
726
  segments:
727
727
  - 0
728
- hash: 77075375696592851
728
+ hash: 3936393471201572148
729
729
  required_rubygems_version: !ruby/object:Gem::Requirement
730
730
  none: false
731
731
  requirements:
@@ -734,7 +734,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
734
734
  version: '0'
735
735
  segments:
736
736
  - 0
737
- hash: 77075375696592851
737
+ hash: 3936393471201572148
738
738
  requirements: []
739
739
  rubyforge_project:
740
740
  rubygems_version: 1.8.24