fb_page_api 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4410e33b80aaa32215e5176b91d94d6774274f2a
4
- data.tar.gz: 066d792cd63b81cb38e00710962e40972ef06511
3
+ metadata.gz: 6a394ee438f8ff148dc5dc0660b3eaa200883af0
4
+ data.tar.gz: 1501899c12a975ff3b89d4b3b2ef8670c42fec12
5
5
  SHA512:
6
- metadata.gz: c1c0cd3cd9b59b2392118dc95c2057a516fd005213cfc0a8429553d5eb6ad836611ec29c8f861d4d3479b01648157288641403ec224ca761f703f9c24f7d6cfd
7
- data.tar.gz: 64cd4842920308d9156a4a4fb4477d6612f83d48378ace81f6af3142d8a629d6abcb09c8e1f93c3659e3ecb4213b033e51573ab47c93c76c3895c9aa2fe29e45
6
+ metadata.gz: 9cbd2a75a51e7708516774cbec553e595d5a642984f3780767da46c0adc33dddeff10776c7d334ebe93bb685f4afc9af52299d32d7f310e603def732b66c4874
7
+ data.tar.gz: 86f30898ab8e33505448528e2a2229cc275d10bf69cd14804e860e88cf8076710c6bbbd77f12e42d8a62b2d371841eb628f2b5b3b9bf249dc5461f06ccf1ce86
@@ -11,7 +11,7 @@ module FbPageApi
11
11
  options = args.extract_options!
12
12
  @collection = []
13
13
  begin
14
- rs = HTTParty.get(api_endpoint, query: body_params(options))
14
+ rs = http_request(:get, api_endpoint, query: body_params(options))
15
15
  data = rs.parsed_response['data']
16
16
  if data.present?
17
17
  @collection = @collection | data
@@ -22,16 +22,16 @@ module FbPageApi
22
22
  end
23
23
 
24
24
  def get(object_id)
25
- HTTParty.get(object_api_endpoint(object_id), query: body_params)
25
+ http_request(:get, object_api_endpoint(object_id), query: body_params).parsed_response
26
26
  end
27
27
 
28
28
  def delete(object_id)
29
- HTTParty.delete(object_api_endpoint(object_id), query: body_params)
29
+ http_request(:delete, object_api_endpoint(object_id), query: body_params).parsed_response
30
30
  end
31
31
 
32
32
  def create(*args)
33
33
  options = args.extract_options!
34
- HTTParty.post(api_endpoint, query: body_params(options))
34
+ http_request(:post, api_endpoint, query: body_params(options)).parsed_response
35
35
  end
36
36
 
37
37
  private
@@ -39,6 +39,14 @@ module FbPageApi
39
39
  raise 'Please override this method in inherit class'
40
40
  end
41
41
 
42
+ def http_request(method, *args)
43
+ rs = HTTParty.send(method, *args)
44
+ if rs.code != 200
45
+ raise rs.parsed_response['error']['message']
46
+ end
47
+ rs
48
+ end
49
+
42
50
  def api_endpoint
43
51
  "#{Config.api_endpoint}/#{self.parent_id}/#{edge_name}"
44
52
  end
@@ -1,3 +1,3 @@
1
1
  module FbPageApi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_page_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tuan Mai