Class: SearchApi::TikTokProfileRequest
- Defined in:
- lib/searchapi/tiktok_profile_request.rb
Constant Summary
Constants inherited from Request
Instance Method Summary collapse
Methods inherited from Request
Constructor Details
This class inherits a constructor from SearchApi::Request
Instance Method Details
#profile(username, options = nil, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/searchapi/tiktok_profile_request.rb', line 4 def profile( username, = nil, &block ) if = .is_a?( TikTokProfileOptions ) ? : TikTokProfileOptions.build!( .to_h ) = .to_h else = { engine: 'tiktok_profile' } end [ :username ] = username.to_s response = get( "#{ BASE_URI }/search", , &block ) attributes = ( JSON.parse( response.body, symbolize_names: true ) rescue nil ) result = if response.success? TikTokProfileResult.new( attributes || {} ) else ErrorResult.new( response.status, attributes ) end ResponseMethods.install( response, result ) end |