facebookads 0.2.11.0 → 0.999

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +5 -5
  2. metadata +13 -370
  3. data/LICENSE.txt +0 -17
  4. data/README.md +0 -222
  5. data/lib/facebook_ads/ad_object.rb +0 -179
  6. data/lib/facebook_ads/ad_objects/ad.rb +0 -220
  7. data/lib/facebook_ads/ad_objects/ad_account.rb +0 -672
  8. data/lib/facebook_ads/ad_objects/ad_account_ad_rules_history.rb +0 -45
  9. data/lib/facebook_ads/ad_objects/ad_account_delivery_estimate.rb +0 -64
  10. data/lib/facebook_ads/ad_objects/ad_account_roas.rb +0 -97
  11. data/lib/facebook_ads/ad_objects/ad_account_targeting_unified.rb +0 -146
  12. data/lib/facebook_ads/ad_objects/ad_account_user.rb +0 -39
  13. data/lib/facebook_ads/ad_objects/ad_activity.rb +0 -124
  14. data/lib/facebook_ads/ad_objects/ad_asset_feed_spec.rb +0 -90
  15. data/lib/facebook_ads/ad_objects/ad_asset_feed_spec_asset_label.rb +0 -37
  16. data/lib/facebook_ads/ad_objects/ad_asset_feed_spec_body.rb +0 -39
  17. data/lib/facebook_ads/ad_objects/ad_asset_feed_spec_caption.rb +0 -39
  18. data/lib/facebook_ads/ad_objects/ad_asset_feed_spec_description.rb +0 -39
  19. data/lib/facebook_ads/ad_objects/ad_asset_feed_spec_group_rule.rb +0 -43
  20. data/lib/facebook_ads/ad_objects/ad_asset_feed_spec_image.rb +0 -41
  21. data/lib/facebook_ads/ad_objects/ad_asset_feed_spec_link_url.rb +0 -41
  22. data/lib/facebook_ads/ad_objects/ad_asset_feed_spec_target_rule.rb +0 -45
  23. data/lib/facebook_ads/ad_objects/ad_asset_feed_spec_title.rb +0 -39
  24. data/lib/facebook_ads/ad_objects/ad_asset_feed_spec_video.rb +0 -41
  25. data/lib/facebook_ads/ad_objects/ad_async_request.rb +0 -67
  26. data/lib/facebook_ads/ad_objects/ad_async_request_set.rb +0 -68
  27. data/lib/facebook_ads/ad_objects/ad_async_request_set_notification_result.rb +0 -38
  28. data/lib/facebook_ads/ad_objects/ad_campaign_delivery_estimate.rb +0 -64
  29. data/lib/facebook_ads/ad_objects/ad_creative.rb +0 -172
  30. data/lib/facebook_ads/ad_objects/ad_creative_collection_thumbnail_info.rb +0 -39
  31. data/lib/facebook_ads/ad_objects/ad_creative_link_data.rb +0 -75
  32. data/lib/facebook_ads/ad_objects/ad_creative_link_data_app_link_spec.rb +0 -40
  33. data/lib/facebook_ads/ad_objects/ad_creative_link_data_call_to_action.rb +0 -80
  34. data/lib/facebook_ads/ad_objects/ad_creative_link_data_call_to_action_value.rb +0 -46
  35. data/lib/facebook_ads/ad_objects/ad_creative_link_data_child_attachment.rb +0 -47
  36. data/lib/facebook_ads/ad_objects/ad_creative_link_data_image_overlay_spec.rb +0 -94
  37. data/lib/facebook_ads/ad_objects/ad_creative_object_story_spec.rb +0 -43
  38. data/lib/facebook_ads/ad_objects/ad_creative_offer_data.rb +0 -44
  39. data/lib/facebook_ads/ad_objects/ad_creative_photo_data.rb +0 -43
  40. data/lib/facebook_ads/ad_objects/ad_creative_place_data.rb +0 -42
  41. data/lib/facebook_ads/ad_objects/ad_creative_post_click_configuration.rb +0 -38
  42. data/lib/facebook_ads/ad_objects/ad_creative_text_data.rb +0 -37
  43. data/lib/facebook_ads/ad_objects/ad_creative_video_data.rb +0 -53
  44. data/lib/facebook_ads/ad_objects/ad_image.rb +0 -58
  45. data/lib/facebook_ads/ad_objects/ad_keyword_stats.rb +0 -55
  46. data/lib/facebook_ads/ad_objects/ad_label.rb +0 -57
  47. data/lib/facebook_ads/ad_objects/ad_place_page_set.rb +0 -44
  48. data/lib/facebook_ads/ad_objects/ad_preview.rb +0 -56
  49. data/lib/facebook_ads/ad_objects/ad_promoted_object.rb +0 -64
  50. data/lib/facebook_ads/ad_objects/ad_recommendation.rb +0 -55
  51. data/lib/facebook_ads/ad_objects/ad_recommendation_data.rb +0 -37
  52. data/lib/facebook_ads/ad_objects/ad_report_run.rb +0 -71
  53. data/lib/facebook_ads/ad_objects/ad_rule.rb +0 -56
  54. data/lib/facebook_ads/ad_objects/ad_rule_evaluation_spec.rb +0 -44
  55. data/lib/facebook_ads/ad_objects/ad_rule_execution_options.rb +0 -44
  56. data/lib/facebook_ads/ad_objects/ad_rule_execution_spec.rb +0 -49
  57. data/lib/facebook_ads/ad_objects/ad_rule_filters.rb +0 -55
  58. data/lib/facebook_ads/ad_objects/ad_rule_history.rb +0 -58
  59. data/lib/facebook_ads/ad_objects/ad_rule_history_result.rb +0 -45
  60. data/lib/facebook_ads/ad_objects/ad_rule_history_result_action.rb +0 -40
  61. data/lib/facebook_ads/ad_objects/ad_rule_schedule.rb +0 -39
  62. data/lib/facebook_ads/ad_objects/ad_rule_schedule_spec.rb +0 -38
  63. data/lib/facebook_ads/ad_objects/ad_rule_trigger.rb +0 -63
  64. data/lib/facebook_ads/ad_objects/ad_set.rb +0 -298
  65. data/lib/facebook_ads/ad_objects/ad_study.rb +0 -70
  66. data/lib/facebook_ads/ad_objects/ad_study_cell.rb +0 -39
  67. data/lib/facebook_ads/ad_objects/ad_study_objective.rb +0 -60
  68. data/lib/facebook_ads/ad_objects/ad_video.rb +0 -25
  69. data/lib/facebook_ads/ad_objects/adgroup_placement_specific_review_feedback.rb +0 -43
  70. data/lib/facebook_ads/ad_objects/adgroup_relevance_score.rb +0 -40
  71. data/lib/facebook_ads/ad_objects/adgroup_review_feedback.rb +0 -38
  72. data/lib/facebook_ads/ad_objects/ads_action_stats.rb +0 -55
  73. data/lib/facebook_ads/ad_objects/ads_data_partner.rb +0 -37
  74. data/lib/facebook_ads/ad_objects/ads_image_crops.rb +0 -43
  75. data/lib/facebook_ads/ad_objects/ads_insights.rb +0 -217
  76. data/lib/facebook_ads/ad_objects/ads_pixel.rb +0 -67
  77. data/lib/facebook_ads/ad_objects/ads_pixel_stats.rb +0 -40
  78. data/lib/facebook_ads/ad_objects/ads_pixel_stats_result.rb +0 -50
  79. data/lib/facebook_ads/ad_objects/agency_client_declaration.rb +0 -48
  80. data/lib/facebook_ads/ad_objects/android_app_link.rb +0 -40
  81. data/lib/facebook_ads/ad_objects/app_links.rb +0 -43
  82. data/lib/facebook_ads/ad_objects/broad_targeting_categories.rb +0 -46
  83. data/lib/facebook_ads/ad_objects/business.rb +0 -195
  84. data/lib/facebook_ads/ad_objects/business_ad_account_request.rb +0 -37
  85. data/lib/facebook_ads/ad_objects/business_page_request.rb +0 -37
  86. data/lib/facebook_ads/ad_objects/campaign.rb +0 -227
  87. data/lib/facebook_ads/ad_objects/check_batch_request_status.rb +0 -40
  88. data/lib/facebook_ads/ad_objects/conversion_action_query.rb +0 -62
  89. data/lib/facebook_ads/ad_objects/custom_audience.rb +0 -173
  90. data/lib/facebook_ads/ad_objects/custom_audience_ad_account.rb +0 -36
  91. data/lib/facebook_ads/ad_objects/custom_audience_data_source.rb +0 -104
  92. data/lib/facebook_ads/ad_objects/custom_audience_permission.rb +0 -41
  93. data/lib/facebook_ads/ad_objects/custom_audience_prefill_state.rb +0 -39
  94. data/lib/facebook_ads/ad_objects/custom_audience_session.rb +0 -44
  95. data/lib/facebook_ads/ad_objects/custom_audience_status.rb +0 -38
  96. data/lib/facebook_ads/ad_objects/custom_audiences_tos.rb +0 -38
  97. data/lib/facebook_ads/ad_objects/custom_conversion.rb +0 -88
  98. data/lib/facebook_ads/ad_objects/custom_conversion_stats_result.rb +0 -50
  99. data/lib/facebook_ads/ad_objects/day_part.rb +0 -40
  100. data/lib/facebook_ads/ad_objects/delivery_check.rb +0 -40
  101. data/lib/facebook_ads/ad_objects/delivery_check_extra_info.rb +0 -39
  102. data/lib/facebook_ads/ad_objects/delivery_estimate.rb +0 -41
  103. data/lib/facebook_ads/ad_objects/domain.rb +0 -37
  104. data/lib/facebook_ads/ad_objects/event.rb +0 -80
  105. data/lib/facebook_ads/ad_objects/event_source_group.rb +0 -43
  106. data/lib/facebook_ads/ad_objects/external_event_source.rb +0 -38
  107. data/lib/facebook_ads/ad_objects/flexible_targeting.rb +0 -64
  108. data/lib/facebook_ads/ad_objects/funding_source_details.rb +0 -39
  109. data/lib/facebook_ads/ad_objects/funding_source_details_coupon.rb +0 -40
  110. data/lib/facebook_ads/ad_objects/helpers/custom_audience_helpers.rb +0 -170
  111. data/lib/facebook_ads/ad_objects/hotel.rb +0 -61
  112. data/lib/facebook_ads/ad_objects/hotel_room.rb +0 -44
  113. data/lib/facebook_ads/ad_objects/id_name.rb +0 -37
  114. data/lib/facebook_ads/ad_objects/ios_app_link.rb +0 -39
  115. data/lib/facebook_ads/ad_objects/lead.rb +0 -47
  116. data/lib/facebook_ads/ad_objects/lead_gen_qualifier.rb +0 -40
  117. data/lib/facebook_ads/ad_objects/lead_gen_question.rb +0 -43
  118. data/lib/facebook_ads/ad_objects/lead_gen_question_option.rb +0 -38
  119. data/lib/facebook_ads/ad_objects/leadgen_form.rb +0 -73
  120. data/lib/facebook_ads/ad_objects/legacy_business_ad_account_request.rb +0 -38
  121. data/lib/facebook_ads/ad_objects/lookalike_spec.rb +0 -43
  122. data/lib/facebook_ads/ad_objects/minimum_budget.rb +0 -41
  123. data/lib/facebook_ads/ad_objects/offline_conversion_data_set.rb +0 -99
  124. data/lib/facebook_ads/ad_objects/offsite_pixel.rb +0 -57
  125. data/lib/facebook_ads/ad_objects/outcome_prediction_point.rb +0 -40
  126. data/lib/facebook_ads/ad_objects/partner_category.rb +0 -51
  127. data/lib/facebook_ads/ad_objects/product_catalog.rb +0 -287
  128. data/lib/facebook_ads/ad_objects/product_catalog_hotel_rooms_batch.rb +0 -50
  129. data/lib/facebook_ads/ad_objects/product_catalog_image_settings.rb +0 -38
  130. data/lib/facebook_ads/ad_objects/product_catalog_image_settings_operation.rb +0 -37
  131. data/lib/facebook_ads/ad_objects/product_catalog_pricing_variables_batch.rb +0 -50
  132. data/lib/facebook_ads/ad_objects/product_feed.rb +0 -91
  133. data/lib/facebook_ads/ad_objects/product_feed_schedule.rb +0 -62
  134. data/lib/facebook_ads/ad_objects/product_feed_upload.rb +0 -50
  135. data/lib/facebook_ads/ad_objects/product_feed_upload_error.rb +0 -49
  136. data/lib/facebook_ads/ad_objects/product_feed_upload_error_sample.rb +0 -37
  137. data/lib/facebook_ads/ad_objects/product_group.rb +0 -94
  138. data/lib/facebook_ads/ad_objects/product_item.rb +0 -148
  139. data/lib/facebook_ads/ad_objects/product_item_commerce_insights.rb +0 -39
  140. data/lib/facebook_ads/ad_objects/product_set.rb +0 -45
  141. data/lib/facebook_ads/ad_objects/product_variant.rb +0 -39
  142. data/lib/facebook_ads/ad_objects/profile_picture_source.rb +0 -52
  143. data/lib/facebook_ads/ad_objects/rate_card.rb +0 -39
  144. data/lib/facebook_ads/ad_objects/reach_estimate.rb +0 -62
  145. data/lib/facebook_ads/ad_objects/reach_frequency_prediction.rb +0 -89
  146. data/lib/facebook_ads/ad_objects/reach_frequency_spec.rb +0 -43
  147. data/lib/facebook_ads/ad_objects/rev_share_policy.rb +0 -38
  148. data/lib/facebook_ads/ad_objects/roas_cohorts_data.rb +0 -41
  149. data/lib/facebook_ads/ad_objects/roas_cohorts_per_cohort_interval_unit.rb +0 -38
  150. data/lib/facebook_ads/ad_objects/targeting.rb +0 -133
  151. data/lib/facebook_ads/ad_objects/targeting_dynamic_rule.rb +0 -44
  152. data/lib/facebook_ads/ad_objects/targeting_geo_location.rb +0 -47
  153. data/lib/facebook_ads/ad_objects/targeting_geo_location_city.rb +0 -43
  154. data/lib/facebook_ads/ad_objects/targeting_geo_location_custom_location.rb +0 -50
  155. data/lib/facebook_ads/ad_objects/targeting_geo_location_electoral_district.rb +0 -40
  156. data/lib/facebook_ads/ad_objects/targeting_geo_location_market.rb +0 -40
  157. data/lib/facebook_ads/ad_objects/targeting_geo_location_place.rb +0 -45
  158. data/lib/facebook_ads/ad_objects/targeting_geo_location_political_district.rb +0 -40
  159. data/lib/facebook_ads/ad_objects/targeting_geo_location_region.rb +0 -39
  160. data/lib/facebook_ads/ad_objects/targeting_geo_location_zip.rb +0 -41
  161. data/lib/facebook_ads/ad_objects/targeting_product_audience_spec.rb +0 -39
  162. data/lib/facebook_ads/ad_objects/targeting_product_audience_sub_spec.rb +0 -38
  163. data/lib/facebook_ads/ad_objects/targeting_sentence_line.rb +0 -38
  164. data/lib/facebook_ads/ad_objects/transaction.rb +0 -57
  165. data/lib/facebook_ads/ad_objects/transaction_currency_amount.rb +0 -39
  166. data/lib/facebook_ads/ad_objects/user.rb +0 -130
  167. data/lib/facebook_ads/ad_objects/user_lead_gen_disclaimer_response.rb +0 -38
  168. data/lib/facebook_ads/ad_objects/user_lead_gen_field_data.rb +0 -38
  169. data/lib/facebook_ads/ad_objects/video_thumbnail.rb +0 -42
  170. data/lib/facebook_ads/ad_objects/web_app_link.rb +0 -38
  171. data/lib/facebook_ads/ad_objects/windows_app_link.rb +0 -40
  172. data/lib/facebook_ads/ad_objects/windows_phone_app_link.rb +0 -39
  173. data/lib/facebook_ads/api_request.rb +0 -123
  174. data/lib/facebook_ads/api_response.rb +0 -47
  175. data/lib/facebook_ads/batch_api/batch.rb +0 -86
  176. data/lib/facebook_ads/batch_api/batch_proxy.rb +0 -67
  177. data/lib/facebook_ads/config.rb +0 -43
  178. data/lib/facebook_ads/edge.rb +0 -184
  179. data/lib/facebook_ads/errors.rb +0 -55
  180. data/lib/facebook_ads/field_types/ad_object.rb +0 -37
  181. data/lib/facebook_ads/field_types/base.rb +0 -33
  182. data/lib/facebook_ads/field_types/boolean.rb +0 -25
  183. data/lib/facebook_ads/field_types/datetime.rb +0 -51
  184. data/lib/facebook_ads/field_types/double.rb +0 -29
  185. data/lib/facebook_ads/field_types/enum.rb +0 -31
  186. data/lib/facebook_ads/field_types/integer.rb +0 -33
  187. data/lib/facebook_ads/field_types/list.rb +0 -57
  188. data/lib/facebook_ads/field_types/object.rb +0 -33
  189. data/lib/facebook_ads/field_types/string_type.rb +0 -34
  190. data/lib/facebook_ads/field_types/upload_file.rb +0 -121
  191. data/lib/facebook_ads/field_types.rb +0 -65
  192. data/lib/facebook_ads/fields.rb +0 -66
  193. data/lib/facebook_ads/helpers/edge_helpers.rb +0 -57
  194. data/lib/facebook_ads/helpers/node_helpers.rb +0 -80
  195. data/lib/facebook_ads/helpers/shortcuts.rb +0 -34
  196. data/lib/facebook_ads/param_set.rb +0 -74
  197. data/lib/facebook_ads/ruby2patch.rb +0 -27
  198. data/lib/facebook_ads/session.rb +0 -98
  199. data/lib/facebook_ads/utils/utils.rb +0 -29
  200. data/lib/facebook_ads/version.rb +0 -24
  201. data/lib/facebook_ads/videos/video_io.rb +0 -25
  202. data/lib/facebook_ads/videos/video_request.rb +0 -42
  203. data/lib/facebook_ads.rb +0 -72
  204. data/lib/facebookads.rb +0 -1
@@ -1,121 +0,0 @@
1
- # Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
2
- #
3
- # You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
4
- # copy, modify, and distribute this software in source code or binary form for use
5
- # in connection with the web services and APIs provided by Facebook.
6
- #
7
- # As with any software that integrates with the Facebook platform, your use of
8
- # this software is subject to the Facebook Platform Policy
9
- # [http://developers.facebook.com/policy/]. This copyright notice shall be
10
- # included in all copies or substantial portions of the software.
11
- #
12
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
14
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
16
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
-
19
- require 'tempfile'
20
-
21
- module FacebookAds
22
- module FieldTypes
23
- class UploadFile < Base
24
- register 'file'
25
-
26
- MIME_TYPES = {
27
- zip: {
28
- 'zip' => 'application/zip'
29
- },
30
- image: {
31
- 'jpg' => 'image/jpeg',
32
- 'jpeg' => 'image/jpeg',
33
- 'png' => 'image/png',
34
- 'gif' => 'image/gif',
35
- 'tiff' => 'image/tiff',
36
- },
37
- video: {
38
- '3g2' => 'video/3gpp2',
39
- '3gp' => 'video/3gpp',
40
- '3gpp' => 'video/3gpp',
41
- 'asf' => 'application/vnd.ms-asf',
42
- 'avi' => 'video/x-msvideo',
43
- 'dat' => 'application/octet-stream',
44
- 'divx' => 'video/divx',
45
- 'dv' => 'video/DV',
46
- 'f4v' => 'video/mp4',
47
- 'flv' => 'video/x-flv',
48
- 'gif' => 'image/gif',
49
- 'm2ts' => 'video/mpeg',
50
- 'm4v' => 'video/vnd.objectvideo',
51
- 'mkv' => 'video/x-matroska',
52
- 'mod' => 'video/mod',
53
- 'mov' => 'video/quicktime',
54
- 'mp4' => 'application/mp4',
55
- 'mpe' => 'video/mpeg',
56
- 'mpeg' => 'video/mpeg',
57
- 'mpeg4' => 'video/mpeg',
58
- 'mpg' => 'video/mpeg',
59
- 'mts' => 'model/vnd.mts',
60
- 'nsv' => 'application/x-winamp',
61
- 'ogm' => 'application/octet-stream',
62
- 'ogv' => 'video/ogg',
63
- 'qt' => 'video/quicktime',
64
- 'tod' => 'application/octet-stream',
65
- 'ts' => 'video/MP2T',
66
- 'vob' => 'video/x-ms-vob',
67
- 'wmv' => 'video/x-ms-wmv',
68
- },
69
- product_feed: {
70
- 'csv' => 'text/csv',
71
- 'tsv' => 'text/tab-separated-values',
72
- 'xml' => 'text/xml ',
73
- }
74
- }
75
-
76
- def serialize(value)
77
- case value
78
- when String, File, Tempfile
79
- if value.is_a?(String)
80
- raise InvalidParameterError, "No such file: #{value}" unless File.exists?(value)
81
- value = File.new(value)
82
- end
83
-
84
- ext = File.extname(value.path).gsub(/^./,'')
85
- category, content_type = content_type_for(ext)
86
-
87
- raise 'This type of file is not supported' unless content_type
88
-
89
- if category == :video
90
- FacebookAds::VideoIO.new(value, content_type)
91
- else
92
- ::UploadIO.new(value, content_type)
93
- end
94
- when UploadIO
95
- value
96
- # when etc etc TODO Rails/Sinatra Upload
97
- else
98
- raise 'Unknown data type this field'
99
- end
100
- end
101
-
102
- private
103
- def content_type_for(ext)
104
- MIME_TYPES.each do |category, types|
105
- if type = types[ext]
106
- return [category, type]
107
- end
108
- end
109
- nil
110
- end
111
-
112
- def self.acceptable?(value)
113
- [File, Tempfile, UploadIO].each do |type|
114
- return true if value.is_a?(type)
115
- end
116
-
117
- value.is_a?(String) ? File.exists?(value) : false
118
- end
119
- end
120
- end
121
- end
@@ -1,65 +0,0 @@
1
- # Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
2
- #
3
- # You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
4
- # copy, modify, and distribute this software in source code or binary form for use
5
- # in connection with the web services and APIs provided by Facebook.
6
- #
7
- # As with any software that integrates with the Facebook platform, your use of
8
- # this software is subject to the Facebook Platform Policy
9
- # [http://developers.facebook.com/policy/]. This copyright notice shall be
10
- # included in all copies or substantial portions of the software.
11
- #
12
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
14
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
16
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
-
19
- require 'facebook_ads/field_types/base'
20
-
21
- module FacebookAds
22
- module FieldTypes
23
- def register(*type_names)
24
- @@registry ||= {}
25
- type_names.each do |type_name|
26
- @@registry[type_name] = self
27
- end
28
- end
29
-
30
- def lookup(type_name)
31
- @@registry && @@registry[type_name]
32
- end
33
-
34
- def for(type_spec)
35
- if type_spec.is_a?(Hash)
36
- type_key = type_spec.keys[0]
37
-
38
- if field_type = lookup(type_key)
39
- field_type.new(type_spec[type_key])
40
- else
41
- raise "Invalid type: #{type_key}"
42
- end
43
- else
44
- if (field_type = lookup(type_spec))
45
- field_type.new
46
- else
47
- begin
48
- ad_object_class = FacebookAds.const_get(type_spec)
49
- field_type = lookup('ad_object')
50
- field_type.new(ad_object_class)
51
- rescue NameError
52
- # fallback to string class if nothing matches
53
- lookup('string').new
54
- end
55
- end
56
- end
57
- end
58
-
59
- extend self
60
- end
61
- end
62
-
63
- Dir.glob(File.expand_path(File.join(__FILE__, '..', 'field_types', '*.rb'))).each do |file|
64
- require file
65
- end
@@ -1,66 +0,0 @@
1
- # Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
2
- #
3
- # You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
4
- # copy, modify, and distribute this software in source code or binary form for use
5
- # in connection with the web services and APIs provided by Facebook.
6
- #
7
- # As with any software that integrates with the Facebook platform, your use of
8
- # this software is subject to the Facebook Platform Policy
9
- # [http://developers.facebook.com/policy/]. This copyright notice shall be
10
- # included in all copies or substantial portions of the software.
11
- #
12
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
14
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
16
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
-
19
- module FacebookAds
20
- module Fields
21
- def self.included(base)
22
- base.extend ClassMethods
23
- end
24
-
25
- module ClassMethods
26
- attr_accessor :deserializer, :field_types
27
-
28
- def field(name, type, *args)
29
- self.field_types ||= {}
30
- self.field_types[name] = type
31
-
32
- unless name == :id
33
- define_reader(name)
34
- define_writer(name)
35
- end
36
-
37
- self.deserializer ||= ParamSet.new
38
- self.deserializer.has_param(name, type, *args)
39
- end
40
-
41
- def define_reader(name)
42
- define_method(name) do
43
- if !@internal_fields.include?(name)
44
- @internal_fields << name
45
- Utils.logger.warn("#{name} not in the internal_fields")
46
- end
47
-
48
- load! unless loaded?
49
-
50
- if changes.has_key?(name)
51
- changes[name]
52
- else
53
- @attributes[name]
54
- end
55
- end
56
- end
57
-
58
- def define_writer(name)
59
- define_method("#{name}=") do |val|
60
- changes[name] = val
61
- @internal_fields.add(name.to_s)
62
- end
63
- end
64
- end
65
- end
66
- end
@@ -1,57 +0,0 @@
1
- # Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
2
- #
3
- # You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
4
- # copy, modify, and distribute this software in source code or binary form for use
5
- # in connection with the web services and APIs provided by Facebook.
6
- #
7
- # As with any software that integrates with the Facebook platform, your use of
8
- # this software is subject to the Facebook Platform Policy
9
- # [http://developers.facebook.com/policy/]. This copyright notice shall be
10
- # included in all copies or substantial portions of the software.
11
- #
12
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
14
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
16
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
-
19
- require 'digest/md5'
20
- require 'json'
21
-
22
- module FacebookAds
23
- module GraphEdges
24
- def self.included(base)
25
- base.extend ClassMethods
26
- end
27
-
28
- module ClassMethods
29
- def edge_classes
30
- @edge_classes
31
- end
32
-
33
- def has_edge(name, &block)
34
- edge_class = Class.new(Edge)
35
- yield edge_class
36
-
37
- @edge_classes ||= {}
38
- @edge_classes[name] = edge_class
39
-
40
- # delegate to field if name collides
41
- should_delegate = field_types.keys.include?(name)
42
-
43
- define_method(name) do |opts = {}|
44
- @edge_proxies ||= {}
45
-
46
- @edge_proxies["#{name}_#{self.class.options_hash(opts)}"] ||= begin
47
- edge_class.new(name, self, should_delegate, opts)
48
- end
49
- end
50
- end
51
-
52
- def options_hash(opts)
53
- Digest::MD5.hexdigest(JSON.generate(opts))
54
- end
55
- end
56
- end
57
- end
@@ -1,80 +0,0 @@
1
- # Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
2
- #
3
- # You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
4
- # copy, modify, and distribute this software in source code or binary form for use
5
- # in connection with the web services and APIs provided by Facebook.
6
- #
7
- # As with any software that integrates with the Facebook platform, your use of
8
- # this software is subject to the Facebook Platform Policy
9
- # [http://developers.facebook.com/policy/]. This copyright notice shall be
10
- # included in all copies or substantial portions of the software.
11
- #
12
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
14
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
16
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
-
19
- module FacebookAds
20
- module GraphNodes
21
- def self.included(base)
22
- base.extend ClassMethods
23
- end
24
-
25
- module ClassMethods
26
- def has_no_get
27
- include NodeHasNoGet
28
- end
29
-
30
- def has_no_id
31
- include NodeHasNoID
32
- end
33
-
34
- def has_no_post
35
- include NodeHasNoPost
36
- end
37
-
38
- def has_no_delete
39
- include NodeHasNoDelete
40
- end
41
- end
42
- end
43
-
44
- module NodeHasNoGet
45
- def load!
46
- raise 'load! is not supported for this object'
47
- end
48
- end
49
-
50
- module NodeHasNoID
51
- def self.included(base)
52
- base.send(:include, NodeHasNoGet)
53
- base.instance_eval do
54
- def get(id, *args)
55
- raise '#get is not supported for this object'
56
- end
57
- end
58
- end
59
-
60
- def id
61
- raise 'This node has no id'
62
- end
63
- end
64
-
65
- module NodeHasNoPost
66
- def self.included(base)
67
- base.class_eval do
68
- undef :save
69
- end
70
- end
71
- end
72
-
73
- module NodeHasNoDelete
74
- def self.included(base)
75
- base.class_eval do
76
- undef :destroy
77
- end
78
- end
79
- end
80
- end
@@ -1,34 +0,0 @@
1
- # Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
2
- #
3
- # You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
4
- # copy, modify, and distribute this software in source code or binary form for use
5
- # in connection with the web services and APIs provided by Facebook.
6
- #
7
- # As with any software that integrates with the Facebook platform, your use of
8
- # this software is subject to the Facebook Platform Policy
9
- # [http://developers.facebook.com/policy/]. This copyright notice shall be
10
- # included in all copies or substantial portions of the software.
11
- #
12
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
14
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
16
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
-
19
- module FacebookAds
20
- module Shortcuts
21
- def me
22
- User.get('me')
23
- end
24
-
25
- def ad_account(act_id)
26
- act_id = 'act_' + act_id unless act_id =~ /^act_/
27
- AdAccount.get(act_id)
28
- end
29
-
30
- def business(biz_id)
31
- Business.get(biz_id)
32
- end
33
- end
34
- end
@@ -1,74 +0,0 @@
1
- # Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
2
- #
3
- # You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
4
- # copy, modify, and distribute this software in source code or binary form for use
5
- # in connection with the web services and APIs provided by Facebook.
6
- #
7
- # As with any software that integrates with the Facebook platform, your use of
8
- # this software is subject to the Facebook Platform Policy
9
- # [http://developers.facebook.com/policy/]. This copyright notice shall be
10
- # included in all copies or substantial portions of the software.
11
- #
12
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
14
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
16
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
-
19
- module FacebookAds
20
- class ParamSet
21
- def initialize
22
- @params = {}
23
- @accepts_files = false
24
- end
25
-
26
- def has_param(name, type)
27
- @params[name.to_sym] = FieldTypes.for(type)
28
- end
29
-
30
- def accepts_files!
31
- @accepts_files = true
32
- end
33
-
34
- def accepts_files?
35
- @accepts_files
36
- end
37
-
38
- def to_params(data)
39
- Hash[data.map do |key,val|
40
- key = key.to_sym
41
- field_type = @params[key]
42
-
43
- if (!field_type && accepts_files? && FieldTypes::UploadFile.acceptable?(val))
44
- field_type = FieldTypes::UploadFile.new
45
- end
46
-
47
- if (!field_type && val.is_a?(Array)) # dynamic ads
48
- val = JSON.generate(val)
49
- end
50
-
51
- [key, (field_type ? field_type.serialize(val) : val)]
52
- # TODO CollectionProxy=
53
- end]
54
- end
55
-
56
- def from_params(data)
57
- Hash[data.map do |key,val|
58
- key = key.to_sym
59
- field_type = @params[key]
60
-
61
- [key, (field_type ? field_type.deserialize(val) : val)]
62
- end]
63
- end
64
-
65
- # TODO
66
- def deserialize(data)
67
- from_params(data)
68
- end
69
-
70
- def empty?
71
- @params.empty?
72
- end
73
- end
74
- end
@@ -1,27 +0,0 @@
1
- # Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
2
- #
3
- # You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
4
- # copy, modify, and distribute this software in source code or binary form for use
5
- # in connection with the web services and APIs provided by Facebook.
6
- #
7
- # As with any software that integrates with the Facebook platform, your use of
8
- # this software is subject to the Facebook Platform Policy
9
- # [http://developers.facebook.com/policy/]. This copyright notice shall be
10
- # included in all copies or substantial portions of the software.
11
- #
12
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
14
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
16
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
-
19
- class Hash
20
- def dig(k, *ks)
21
- key?(k) ? (ks.empty? ? self[k] : self[k].dig(*ks)) : nil
22
- end unless method_defined?(:dig)
23
-
24
- def compact
25
- self.select { |_, value| !value.nil? }
26
- end unless method_defined?(:compact)
27
- end
@@ -1,98 +0,0 @@
1
- # Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
2
- #
3
- # You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
4
- # copy, modify, and distribute this software in source code or binary form for use
5
- # in connection with the web services and APIs provided by Facebook.
6
- #
7
- # As with any software that integrates with the Facebook platform, your use of
8
- # this software is subject to the Facebook Platform Policy
9
- # [http://developers.facebook.com/policy/]. This copyright notice shall be
10
- # included in all copies or substantial portions of the software.
11
- #
12
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
14
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
16
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
-
19
- require 'faraday'
20
- require 'openssl'
21
- require 'logger'
22
- require 'facebook_ads/videos/video_request'
23
-
24
- module FacebookAds
25
- class Session
26
- attr_accessor :access_token, :app_secret, :api_version, :server_host
27
-
28
- def initialize(access_token: nil,
29
- app_secret: nil,
30
- server_host: FacebookAds.config.server_host,
31
- api_version: FacebookAds.config.api_version)
32
- @access_token = access_token
33
- @app_secret = app_secret
34
- @server_host = server_host
35
- @api_version = api_version
36
- end
37
-
38
- def request(method, path, params = nil)
39
- case method
40
- when :get, :post, :delete
41
- api_conn.send(method, path.gsub(/^\//,''), params) do |req|
42
- req.headers[:user_agent] = "fb-ruby-ads-api-sdk-#{VERSION}".freeze
43
- req.params[:access_token] = access_token
44
- req.params[:appsecret_proof] = appsecret_proof if app_secret
45
- end
46
- else
47
- raise 'Unsupported HTTP method: ' + method
48
- end
49
- end
50
-
51
- def appsecret_proof
52
- OpenSSL::HMAC.hexdigest(
53
- OpenSSL::Digest.new('sha256'),
54
- @app_secret,
55
- @access_token
56
- )
57
- end
58
-
59
- private
60
- def api_conn
61
- @api_conn ||= Faraday.new(url: api_base_path) do |faraday|
62
- faraday.use FacebookAds::HTTPService::VideoRequest
63
- faraday.request :multipart
64
- # TODO Json Request
65
- # TODO URL Encode - stringify json
66
- faraday.request :url_encoded
67
-
68
- faraday.response :logger, Utils.logger, bodies: FacebookAds.config.log_api_bodies
69
- faraday.adapter Faraday.default_adapter
70
- end
71
- end
72
-
73
- def api_base_path
74
- "https://#{self.server_host}/#{self.api_version}/".freeze
75
- end
76
-
77
- class << self
78
- def default_session
79
- # TODO
80
- @default_session ||= new( access_token: FacebookAds.config.access_token,
81
- app_secret: FacebookAds.config.app_secret)
82
- end
83
-
84
- def default_session=(session)
85
- # TODO
86
- @default_session = session
87
- end
88
-
89
- def current_session
90
- @@current_session ||= default_session
91
- end
92
-
93
- def current_session=(session)
94
- @@current_session = session
95
- end
96
- end
97
- end
98
- end
@@ -1,29 +0,0 @@
1
- # Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
2
- #
3
- # You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
4
- # copy, modify, and distribute this software in source code or binary form for use
5
- # in connection with the web services and APIs provided by Facebook.
6
- #
7
- # As with any software that integrates with the Facebook platform, your use of
8
- # this software is subject to the Facebook Platform Policy
9
- # [http://developers.facebook.com/policy/]. This copyright notice shall be
10
- # included in all copies or substantial portions of the software.
11
- #
12
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
14
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
16
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
-
19
- require 'logger'
20
-
21
- module FacebookAds
22
- module Utils
23
- extend self
24
-
25
- attr_accessor :logger
26
- self.logger = Logger.new(STDERR)
27
- self.logger.level = Logger::ERROR
28
- end
29
- end
@@ -1,24 +0,0 @@
1
- # Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
2
- #
3
- # You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
4
- # copy, modify, and distribute this software in source code or binary form for use
5
- # in connection with the web services and APIs provided by Facebook.
6
- #
7
- # As with any software that integrates with the Facebook platform, your use of
8
- # this software is subject to the Facebook Platform Policy
9
- # [http://developers.facebook.com/policy/]. This copyright notice shall be
10
- # included in all copies or substantial portions of the software.
11
- #
12
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
14
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
16
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
-
19
- # FB:AUTOGEN
20
-
21
- module FacebookAds
22
- VERSION = '0.2.11.0'
23
- API_VERSION = '2.11'
24
- end