api-client 2.7.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.ruby-version +1 -1
 - data/CHANGELOG.md +4 -0
 - data/README.md +16 -0
 - data/examples/controllers/book_controller.rb +2 -2
 - data/examples/controllers/user_controller.rb +2 -2
 - data/lib/api-client/class_methods.rb +3 -3
 - data/lib/api-client/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 748d015f42e4dbf265255c6d94dd5b930a292be8
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f3ed098def84e5ee960bd9a4b2868fc882274d24
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a10e8dba5c3d37e29829f651f5cc78dcc27e416501ca64a7d70f4d9220b64d28bb019f09afe3d93a8ba4ef21d55f1860616ba9548560153409e038242d0c8037
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c7a04bcd27fbc508bfa567437bd63109c741d7a1e43e9c9aa3d610cee2313bc9beb33ba77c6d9dcbccc7fb6b62b5659bf1206edd6e6369bb3cf720623cd31050
         
     | 
    
        data/.ruby-version
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            2.0.0
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -190,6 +190,22 @@ ApiClient.parallel do 
     | 
|
| 
       190 
190 
     | 
    
         
             
            end
         
     | 
| 
       191 
191 
     | 
    
         
             
            ```
         
     | 
| 
       192 
192 
     | 
    
         | 
| 
      
 193 
     | 
    
         
            +
            ## Migrating from 2.*.* to 3.0.0
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
            Since version 3.0.0 is not necessarily set the root_node on the attributes when calling methods on the class.
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
            Before:
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 200 
     | 
    
         
            +
            @user = User.create({ :user => attributes })
         
     | 
| 
      
 201 
     | 
    
         
            +
            ```
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
            After:
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 206 
     | 
    
         
            +
            @user = User.create(attributes )
         
     | 
| 
      
 207 
     | 
    
         
            +
            ```
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
       193 
209 
     | 
    
         
             
            ## More Examples
         
     | 
| 
       194 
210 
     | 
    
         
             
            [Project](https://github.com/zertico/api-client/tree/master/examples)
         
     | 
| 
       195 
211 
     | 
    
         | 
| 
         @@ -15,7 +15,7 @@ class BookController < ApplicationController 
     | 
|
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
              # It will hit http://api.example.com/books with a post request
         
     | 
| 
       17 
17 
     | 
    
         
             
              def create
         
     | 
| 
       18 
     | 
    
         
            -
                @book = Book.create( 
     | 
| 
      
 18 
     | 
    
         
            +
                @book = Book.create(params[:book])
         
     | 
| 
       19 
19 
     | 
    
         
             
                respond_with(@user)
         
     | 
| 
       20 
20 
     | 
    
         
             
              end
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
         @@ -27,7 +27,7 @@ class BookController < ApplicationController 
     | 
|
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
              # It will hit http://api.example.com/books with a put request
         
     | 
| 
       29 
29 
     | 
    
         
             
              def update
         
     | 
| 
       30 
     | 
    
         
            -
                @book = Book.update_attributes(params[:id],  
     | 
| 
      
 30 
     | 
    
         
            +
                @book = Book.update_attributes(params[:id], params[:book])
         
     | 
| 
       31 
31 
     | 
    
         
             
                respond_with(@book)
         
     | 
| 
       32 
32 
     | 
    
         
             
              end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
         @@ -15,7 +15,7 @@ class UserController < ApplicationController 
     | 
|
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
              # It will hit http://api.example.com/users with a post request
         
     | 
| 
       17 
17 
     | 
    
         
             
              def create
         
     | 
| 
       18 
     | 
    
         
            -
                @user = User.post( 
     | 
| 
      
 18 
     | 
    
         
            +
                @user = User.post(params[:user])
         
     | 
| 
       19 
19 
     | 
    
         
             
                respond_with(@user)
         
     | 
| 
       20 
20 
     | 
    
         
             
              end
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
         @@ -27,7 +27,7 @@ class UserController < ApplicationController 
     | 
|
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
              # It will hit http://api.example.com/users with a patch request
         
     | 
| 
       29 
29 
     | 
    
         
             
              def update
         
     | 
| 
       30 
     | 
    
         
            -
                @user = User.patch(params[:id],  
     | 
| 
      
 30 
     | 
    
         
            +
                @user = User.patch(params[:id], params[:user])
         
     | 
| 
       31 
31 
     | 
    
         
             
                respond_with(@user)
         
     | 
| 
       32 
32 
     | 
    
         
             
              end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
         @@ -23,7 +23,7 @@ module ApiClient 
     | 
|
| 
       23 
23 
     | 
    
         
             
                def post(attributes, header = {})
         
     | 
| 
       24 
24 
     | 
    
         
             
                  return new(attributes) if ApiClient.config.mock
         
     | 
| 
       25 
25 
     | 
    
         
             
                  url = "#{ApiClient.config.path[path]}#{self.resource_path}"
         
     | 
| 
       26 
     | 
    
         
            -
                  response = ApiClient::Dispatcher.post(url, attributes, header)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  response = ApiClient::Dispatcher.post(url, { self.root_node.to_sym => attributes }, header)
         
     | 
| 
       27 
27 
     | 
    
         
             
                  build(response, url)
         
     | 
| 
       28 
28 
     | 
    
         
             
                end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
         @@ -37,7 +37,7 @@ module ApiClient 
     | 
|
| 
       37 
37 
     | 
    
         
             
                def put(id, attributes, header = {})
         
     | 
| 
       38 
38 
     | 
    
         
             
                  return new(attributes) if ApiClient.config.mock
         
     | 
| 
       39 
39 
     | 
    
         
             
                  url = "#{ApiClient.config.path[path]}#{self.resource_path}/#{id}"
         
     | 
| 
       40 
     | 
    
         
            -
                  response = ApiClient::Dispatcher.put(url, attributes, header)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  response = ApiClient::Dispatcher.put(url, { self.root_node.to_sym => attributes }, header)
         
     | 
| 
       41 
41 
     | 
    
         
             
                  build(response, url)
         
     | 
| 
       42 
42 
     | 
    
         
             
                end
         
     | 
| 
       43 
43 
     | 
    
         | 
| 
         @@ -51,7 +51,7 @@ module ApiClient 
     | 
|
| 
       51 
51 
     | 
    
         
             
                def patch(id, attributes, header = {})
         
     | 
| 
       52 
52 
     | 
    
         
             
                  return new(attributes) if ApiClient.config.mock
         
     | 
| 
       53 
53 
     | 
    
         
             
                  url = "#{ApiClient.config.path[path]}#{self.resource_path}/#{id}"
         
     | 
| 
       54 
     | 
    
         
            -
                  response = ApiClient::Dispatcher.patch(url, attributes, header)
         
     | 
| 
      
 54 
     | 
    
         
            +
                  response = ApiClient::Dispatcher.patch(url, { self.root_node.to_sym => attributes }, header)
         
     | 
| 
       55 
55 
     | 
    
         
             
                  build(response, url)
         
     | 
| 
       56 
56 
     | 
    
         
             
                end
         
     | 
| 
       57 
57 
     | 
    
         | 
    
        data/lib/api-client/version.rb
    CHANGED