mirror of
https://github.com/nov/fb_graph2
synced 2023-03-27 23:22:15 -04:00
reduce "custom" attributes
This commit is contained in:
parent
f4d856ed3f
commit
bb73e5190a
11 changed files with 58 additions and 25 deletions
|
|
@ -30,28 +30,40 @@ module FbGraph2
|
||||||
Time.parse raw
|
Time.parse raw
|
||||||
when :timestamp
|
when :timestamp
|
||||||
Time.at raw
|
Time.at raw
|
||||||
|
when :actions
|
||||||
|
Collection.new(raw).collect do |_raw_|
|
||||||
|
Struct::Action.new _raw_
|
||||||
|
end
|
||||||
|
when :album
|
||||||
|
Album.new raw[:id], raw
|
||||||
when :application
|
when :application
|
||||||
Application.new raw[:id], raw
|
Application.new raw[:id], raw
|
||||||
|
when :comment
|
||||||
|
Comment.new raw[:id], raw
|
||||||
|
when :group
|
||||||
|
Group.new raw[:id], raw
|
||||||
|
when :image_sources
|
||||||
|
Collection.new(raw).collect do |_raw_|
|
||||||
|
Struct::ImageSource.new _raw_
|
||||||
|
end
|
||||||
when :page
|
when :page
|
||||||
Page.new raw[:id], raw
|
Page.new raw[:id], raw
|
||||||
when :pages
|
when :pages
|
||||||
Collection.new(raw).collect do |_raw_|
|
Collection.new(raw).collect do |_raw_|
|
||||||
Page.new _raw_[:id], _raw_
|
Page.new _raw_[:id], _raw_
|
||||||
end
|
end
|
||||||
|
when :photo
|
||||||
|
Photo.new raw[:id], raw
|
||||||
|
when :picture
|
||||||
|
Struct::Picture.new raw[:data]
|
||||||
when :profile
|
when :profile
|
||||||
as_profile raw
|
as_profile raw
|
||||||
when :profiles
|
when :profiles
|
||||||
Collection.new(raw).collect do |_raw_|
|
Collection.new(raw).collect do |_raw_|
|
||||||
as_profile _raw_
|
as_profile _raw_
|
||||||
end
|
end
|
||||||
when :application
|
|
||||||
Application.new raw[:id], raw
|
|
||||||
when :user
|
when :user
|
||||||
User.new raw[:id], raw
|
User.new raw[:id], raw
|
||||||
when :picture
|
|
||||||
Struct::Picture.new raw[:data]
|
|
||||||
when :album
|
|
||||||
Album.new raw[:id], raw
|
|
||||||
else
|
else
|
||||||
# NOTE: handle these attributes in each class
|
# NOTE: handle these attributes in each class
|
||||||
next
|
next
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@ module FbGraph2
|
||||||
raw: [:can_comment, :can_remove, :comment_count, :like_count, :message, :user_likes],
|
raw: [:can_comment, :can_remove, :comment_count, :like_count, :message, :user_likes],
|
||||||
time: [:created_time],
|
time: [:created_time],
|
||||||
user: [:from],
|
user: [:from],
|
||||||
custom: [:attachment, :message_tags, :parent]
|
comment: [:parent],
|
||||||
|
profiles: [:message_tags],
|
||||||
|
custom: [:attachment]
|
||||||
)
|
)
|
||||||
|
|
||||||
def initialize(id, attributes = {})
|
def initialize(id, attributes = {})
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,9 @@ module FbGraph2
|
||||||
raw: [:description, :is_date_only, :location, :name, :privacy, :ticket_uri, :timezone],
|
raw: [:description, :is_date_only, :location, :name, :privacy, :ticket_uri, :timezone],
|
||||||
time: [:end_time, :start_time, :updated_time],
|
time: [:end_time, :start_time, :updated_time],
|
||||||
page: [:venue],
|
page: [:venue],
|
||||||
custom: [:cover, :owner, :parent_group]
|
profile: [:owner],
|
||||||
|
group: [:parent_group],
|
||||||
|
photo: [:cover]
|
||||||
)
|
)
|
||||||
|
|
||||||
def initialize(id, attributes = {})
|
|
||||||
super
|
|
||||||
# TODO: handle custom attributes.
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -7,12 +7,8 @@ module FbGraph2
|
||||||
:administrator, :bookmark_order, :unread
|
:administrator, :bookmark_order, :unread
|
||||||
],
|
],
|
||||||
time: [:updated_time],
|
time: [:updated_time],
|
||||||
custom: [:cover, :owner, :parent]
|
profile: [:owner, :parent],
|
||||||
|
photo: [:cover]
|
||||||
)
|
)
|
||||||
|
|
||||||
def initialize(id, attributes = {})
|
|
||||||
super
|
|
||||||
# TODO: handle custom attributes.
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -12,8 +12,9 @@ module FbGraph2
|
||||||
time: [:created_time],
|
time: [:created_time],
|
||||||
date: [:birthday],
|
date: [:birthday],
|
||||||
page: [:best_page],
|
page: [:best_page],
|
||||||
|
photo: [:cover],
|
||||||
custom: [
|
custom: [
|
||||||
:category_list, :cover, :context, :hours, :location, :parking, :price_range, :restaurant_services,
|
:category_list, :context, :hours, :location, :parking, :price_range, :restaurant_services,
|
||||||
:restaurant_specialties
|
:restaurant_specialties
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,17 @@
|
||||||
module FbGraph2
|
module FbGraph2
|
||||||
class Photo < Node
|
class Photo < Node
|
||||||
register_attributes(
|
register_attributes(
|
||||||
raw: [:backdated_time_granularity, :height, :icon, :link, :name, :page_story_id, :picture, :position, :source, :width],
|
raw: [
|
||||||
|
:backdated_time_granularity, :height, :icon, :link, :name, :page_story_id, :picture, :position, :source, :width,
|
||||||
|
# NOTE: as cover photo
|
||||||
|
:offset_y, :offset_x
|
||||||
|
],
|
||||||
time: [:backdated_time, :created_time, :updated_time],
|
time: [:backdated_time, :created_time, :updated_time],
|
||||||
page: [:place],
|
page: [:place],
|
||||||
profile: [:from],
|
profile: [:from],
|
||||||
album: [:album],
|
album: [:album],
|
||||||
custom: [:images, :name_tags]
|
image_sources: [:images],
|
||||||
|
custom: [:name_tags]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -12,8 +12,9 @@ module FbGraph2
|
||||||
page: [:place],
|
page: [:place],
|
||||||
profile: [:from],
|
profile: [:from],
|
||||||
profiles: [:to, :with_tags],
|
profiles: [:to, :with_tags],
|
||||||
|
actions: [:actions],
|
||||||
custom: [
|
custom: [
|
||||||
:actions, :message_tags, :privacy, :properties, :shares, :status_type, :type
|
:message_tags, :privacy, :properties, :shares, :status_type, :type
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
9
lib/fb_graph2/struct/action.rb
Normal file
9
lib/fb_graph2/struct/action.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
module FbGraph2
|
||||||
|
class Struct
|
||||||
|
class Action < Struct
|
||||||
|
register_attributes(
|
||||||
|
raw: [:name, :link]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
9
lib/fb_graph2/struct/image_source.rb
Normal file
9
lib/fb_graph2/struct/image_source.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
module FbGraph2
|
||||||
|
class Struct
|
||||||
|
class ImageSource < Struct
|
||||||
|
register_attributes(
|
||||||
|
raw: [:height, :source, :width]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module FbGraph2
|
module FbGraph2
|
||||||
class Struct
|
class Struct
|
||||||
class Poke < Struct
|
class Score < Struct
|
||||||
register_attributes(
|
register_attributes(
|
||||||
raw: [:score],
|
raw: [:score],
|
||||||
user: [:user],
|
user: [:user],
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,8 @@ module FbGraph2
|
||||||
page: [:hometown, :location],
|
page: [:hometown, :location],
|
||||||
pages: [:favorite_athletes, :favorite_teams, :inspirational_people, :languages],
|
pages: [:favorite_athletes, :favorite_teams, :inspirational_people, :languages],
|
||||||
user: [:significant_other],
|
user: [:significant_other],
|
||||||
custom: [:age_range, :context, :cover, :currency, :education, :work]
|
photo: [:cover],
|
||||||
|
custom: [:age_range, :context, :currency, :education, :work]
|
||||||
)
|
)
|
||||||
|
|
||||||
def initialize(id, attributes = {})
|
def initialize(id, attributes = {})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue