Class: InstaScraper::JSON::AccountMedia

Inherits:
InstaScraper::JSON show all
Defined in:
lib/insta_scraper/json/account_media.rb

Instance Attribute Summary collapse

Attributes inherited from InstaScraper::JSON

#response

Instance Method Summary collapse

Methods inherited from InstaScraper::JSON

#data, #raw_json

Constructor Details

#initialize(id:, per_page: 12, end_cursor: nil) ⇒ AccountMedia

Returns a new instance of AccountMedia.



5
6
7
8
9
# File 'lib/insta_scraper/json/account_media.rb', line 5

def initialize(id:, per_page: 12, end_cursor: nil)
  @id = id
  @per_page = per_page
  @end_cursor = end_cursor
end

Instance Attribute Details

#end_cursorObject (readonly)

Returns the value of attribute end_cursor.



3
4
5
# File 'lib/insta_scraper/json/account_media.rb', line 3

def end_cursor
  @end_cursor
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/insta_scraper/json/account_media.rb', line 3

def id
  @id
end

#per_pageObject (readonly)

Returns the value of attribute per_page.



3
4
5
# File 'lib/insta_scraper/json/account_media.rb', line 3

def per_page
  @per_page
end

Instance Method Details

#paramsObject



19
20
21
22
23
24
# File 'lib/insta_scraper/json/account_media.rb', line 19

def params
  {
    query_id: 17888483320059182,
    variables: variables,
  }
end

#urlObject



26
27
28
# File 'lib/insta_scraper/json/account_media.rb', line 26

def url
  "https://www.instagram.com/graphql/query/#{serialize_params}"
end

#variablesObject



11
12
13
14
15
16
17
# File 'lib/insta_scraper/json/account_media.rb', line 11

def variables
  if end_cursor
    "{\"id\":\"#{id}\",\"first\":#{per_page},\"after\":\"#{end_cursor}\"}"
  else
    "{\"id\":\"#{id}\",\"first\":#{per_page}}"
  end
end