File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -834,6 +834,26 @@ def list_push_providers
834834 get ( 'push_providers' )
835835 end
836836
837+ T ::Sig ::WithoutRuntime . sig { params ( filename : String ) . returns ( StreamChat ::StreamResponse ) }
838+ def create_import_url ( filename )
839+ post ( 'import_urls' , data : { filename : filename } )
840+ end
841+
842+ T ::Sig ::WithoutRuntime . sig { params ( path : String , mode : String ) . returns ( StreamChat ::StreamResponse ) }
843+ def create_import ( path , mode )
844+ post ( 'imports' , data : { path : path , mode : mode } )
845+ end
846+
847+ T ::Sig ::WithoutRuntime . sig { params ( id : String ) . returns ( StreamChat ::StreamResponse ) }
848+ def get_import ( id )
849+ get ( "imports/#{ id } " )
850+ end
851+
852+ T ::Sig ::WithoutRuntime . sig { params ( options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
853+ def list_imports ( options )
854+ get ( 'imports' , params : options )
855+ end
856+
837857 private
838858
839859 T ::Sig ::WithoutRuntime . sig { returns ( T ::Hash [ String , String ] ) }
Original file line number Diff line number Diff line change 33require 'jwt'
44require 'securerandom'
55require 'stream-chat'
6+ require 'faraday'
67
78describe StreamChat ::Client do
89 def loop_times ( times )
@@ -709,6 +710,23 @@ def loop_times(times)
709710 expect ( cmd [ 'name' ] ) . not_to eq @cmd
710711 end
711712 end
713+
714+ it 'import end2end' do
715+ url_resp = @client . create_import_url ( "#{ SecureRandom . uuid } .json'" )
716+ expect ( url_resp [ 'upload_url' ] ) . not_to be_empty
717+ expect ( url_resp [ 'path' ] ) . not_to be_empty
718+
719+ Faraday . put ( url_resp [ 'upload_url' ] , '{}' , 'Content-Type' => 'application/json' )
720+
721+ create_resp = @client . create_import ( url_resp [ 'path' ] , 'upsert' )
722+ expect ( create_resp [ 'import_task' ] [ 'id' ] ) . not_to be_empty
723+
724+ get_resp = @client . get_import ( create_resp [ 'import_task' ] [ 'id' ] )
725+ expect ( get_resp [ 'import_task' ] [ 'id' ] ) . to eq create_resp [ 'import_task' ] [ 'id' ]
726+
727+ list_resp = @client . list_imports ( { limit : 1 } )
728+ expect ( list_resp [ 'import_tasks' ] . length ) . to eq 1
729+ end
712730 end
713731
714732 describe 'permissions' do
You can’t perform that action at this time.
0 commit comments