mirror of
https://github.com/nov/fb_graph2
synced 2023-03-27 23:22:15 -04:00
page custom attributes done
This commit is contained in:
parent
32904ec333
commit
968cab225d
9 changed files with 82 additions and 22 deletions
|
@ -24,6 +24,8 @@ module FbGraph2
|
|||
value = case type
|
||||
when :raw
|
||||
raw
|
||||
when :int_flag
|
||||
raw == 1
|
||||
when :date
|
||||
Date.strptime raw, '%m/%d/%Y' rescue raw
|
||||
when :time
|
||||
|
|
|
@ -21,9 +21,9 @@ module FbGraph2
|
|||
register_attributes(
|
||||
raw: [
|
||||
:about, :attire, :band_members, :booking_agent, :can_post, :category, :checkins, :company_overview,
|
||||
:current_location, :description, :directed_by, :founded, :general_info, :general_manager, :hometown,
|
||||
:current_location, :description, :directed_by, :founded, :general_info, :general_manager, :hometown, :hours,
|
||||
:is_permanently_closed, :is_published, :is_unclaimed, :likes, :link, :mission, :name, :phone, :press_contact,
|
||||
:products, :talking_about_count, :username, :website, :were_here_count,
|
||||
:price_range, :products, :talking_about_count, :username, :website, :were_here_count,
|
||||
# NOTE: only within /:user_id/accounts context
|
||||
:perms
|
||||
],
|
||||
|
@ -40,8 +40,9 @@ module FbGraph2
|
|||
:with
|
||||
],
|
||||
custom: [
|
||||
:category_list, :context, :hours, :location, :parking, :price_range, :restaurant_services,
|
||||
:restaurant_specialties
|
||||
:category_list, :context, :location, :parking, :restaurant_services, :restaurant_specialties,
|
||||
# NOTE: undocumented
|
||||
:payment_options
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -52,7 +53,24 @@ module FbGraph2
|
|||
PageCategory.new page_category[:id], page_category
|
||||
end
|
||||
end
|
||||
# TODO: handle other custom attributes.
|
||||
if attributes.include? :context
|
||||
self.context = Struct::Context::PageContext.new attributes[:context]
|
||||
end
|
||||
if attributes.include? :location
|
||||
self.location = Struct::Location.new attributes[:location]
|
||||
end
|
||||
if attributes.include? :parking
|
||||
self.parking = Struct::Parking.new attributes[:parking]
|
||||
end
|
||||
if attributes.include? :restaurant_services
|
||||
self.restaurant_services = Struct::RestaurantServices.new attributes[:restaurant_services]
|
||||
end
|
||||
if attributes.include? :restaurant_specialties
|
||||
self.restaurant_specialties = Struct::RestaurantSpecialties.new attributes[:restaurant_specialties]
|
||||
end
|
||||
if attributes.include? :payment_options
|
||||
self.payment_options = Struct::PaymentOptions.new attributes[:payment_options]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,21 +1,17 @@
|
|||
module FbGraph2
|
||||
class Struct
|
||||
class Context < Struct
|
||||
register_attributes(
|
||||
custom: [:mutual_friends, :mutual_likes]
|
||||
)
|
||||
module Context
|
||||
class UserContext < Struct
|
||||
register_attributes(
|
||||
users: [:mutual_friends],
|
||||
pages: [:mutual_likes]
|
||||
)
|
||||
end
|
||||
|
||||
def initialize(attributes = {})
|
||||
if attributes.include? :mutual_friends
|
||||
self.mutual_friends = Collection.new(attributes[:mutual_friends]).collect do |user|
|
||||
User.new user[:id], user
|
||||
end
|
||||
end
|
||||
if attributes.include? :mutual_likes
|
||||
self.mutual_likes = Collection.new(attributes[:mutual_likes]).collect do |page|
|
||||
Page.new page[:id], page
|
||||
end
|
||||
end
|
||||
class PageContext < Struct
|
||||
register_attributes(
|
||||
users: [:friends_who_like, :friends_tagged_at, :music_listen_friends, :video_watch_friends]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
9
lib/fb_graph2/struct/location.rb
Normal file
9
lib/fb_graph2/struct/location.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module FbGraph2
|
||||
class Struct
|
||||
class Location < Struct
|
||||
register_attributes(
|
||||
raw: [:country, :city, :longitude, :zip, :state, :street, :located_in, :latitude]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
9
lib/fb_graph2/struct/parking.rb
Normal file
9
lib/fb_graph2/struct/parking.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module FbGraph2
|
||||
class Struct
|
||||
class Parking < Struct
|
||||
register_attributes(
|
||||
int_flag: [:street, :lot, :valet]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
9
lib/fb_graph2/struct/payment_options.rb
Normal file
9
lib/fb_graph2/struct/payment_options.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module FbGraph2
|
||||
class Struct
|
||||
class PaymentOptions < Struct
|
||||
register_attributes(
|
||||
int_flag: [:amex, :cash_only, :discover, :mastercard, :visa]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
9
lib/fb_graph2/struct/restaurant_services.rb
Normal file
9
lib/fb_graph2/struct/restaurant_services.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module FbGraph2
|
||||
class Struct
|
||||
class RestaurantServices < Struct
|
||||
register_attributes(
|
||||
int_flag: [:kids, :delivery, :walkins, :catering, :reserve, :groups, :waiter, :outdoor, :takeout]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
9
lib/fb_graph2/struct/restaurant_specialties.rb
Normal file
9
lib/fb_graph2/struct/restaurant_specialties.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module FbGraph2
|
||||
class Struct
|
||||
class RestaurantSpecialties < Struct
|
||||
register_attributes(
|
||||
int_flag: [:coffee, :drinks, :breakfast, :dinner, :lunch]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -69,12 +69,11 @@ module FbGraph2
|
|||
|
||||
def initialize(id, attributes = {})
|
||||
super
|
||||
# TODO: handle custom attributes.
|
||||
if attributes.include? :age_range
|
||||
self.age_range = Struct::AgeRange.new attributes[:age_range]
|
||||
end
|
||||
if attributes.include? :context
|
||||
self.context = Struct::Context.new attributes[:context]
|
||||
self.context = Struct::Context::UserContext.new attributes[:context]
|
||||
end
|
||||
if attributes.include? :currency
|
||||
self.currency = Struct::Currency.new attributes[:currency]
|
||||
|
|
Loading…
Reference in a new issue