json_api_client 0.1.2 → 0.1.3
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/README.md +2 -2
 - data/lib/json_api_client/query/base.rb +1 -1
 - data/lib/json_api_client/resource.rb +21 -8
 - data/lib/json_api_client/result_set.rb +4 -0
 - data/lib/json_api_client/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b850c5b674039c387b45ecaa49c4800a667bf503
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b0a12cdba47effcf2e5708a64852445dc77b494c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: f4f52b341ab65f8993f90c347d0d114c91f1ab269d018190f3e937c38f08c19c725d1be84ef0751364c9b3655536556b05b5a928e19c251deb69c9a0cfa86e89
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d5df64cc6493f06792596c879bad18f031398bc306a6c8fe179d97ff10d8ffc2ce1fc032875b39e4fd030e70265cd4791a0edbc2f1964182a5df783bdaae9a15
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # JsonApiClient [](https://travis-ci.org/chingor13/json_api_client)
         
     | 
| 
      
 1 
     | 
    
         
            +
            # JsonApiClient [](https://travis-ci.org/chingor13/json_api_client) [](https://codeclimate.com/github/chingor13/json_api_client) [](https://codeclimate.com/github/chingor13/json_api_client)
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            This gem is meant to help you build an API client for interacting with REST APIs as laid out by [http://jsonapi.org](http://jsonapi.org). It attempts to give you a query building framework that is easy to understand (it is similar to ActiveRecord scopes).
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
         @@ -115,4 +115,4 @@ module MyApi 
     | 
|
| 
       115 
115 
     | 
    
         
             
            end
         
     | 
| 
       116 
116 
     | 
    
         | 
| 
       117 
117 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
            ```
         
     | 
| 
      
 118 
     | 
    
         
            +
            ```
         
     | 
| 
         @@ -32,7 +32,10 @@ module JsonApiClient 
     | 
|
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                  def create(conditions = {})
         
     | 
| 
       34 
34 
     | 
    
         
             
                    result = run_request(Query::Create.new(self, conditions))
         
     | 
| 
       35 
     | 
    
         
            -
                     
     | 
| 
      
 35 
     | 
    
         
            +
                    if result.has_errors?
         
     | 
| 
      
 36 
     | 
    
         
            +
                      yield(result) if block_given?
         
     | 
| 
      
 37 
     | 
    
         
            +
                      return nil
         
     | 
| 
      
 38 
     | 
    
         
            +
                    end
         
     | 
| 
       36 
39 
     | 
    
         
             
                    result.first
         
     | 
| 
       37 
40 
     | 
    
         
             
                  end
         
     | 
| 
       38 
41 
     | 
    
         | 
| 
         @@ -58,20 +61,30 @@ module JsonApiClient 
     | 
|
| 
       58 
61 
     | 
    
         
             
                end
         
     | 
| 
       59 
62 
     | 
    
         | 
| 
       60 
63 
     | 
    
         
             
                def destroy
         
     | 
| 
       61 
     | 
    
         
            -
                  run_request(Query::Destroy.new(self.class, attributes))
         
     | 
| 
      
 64 
     | 
    
         
            +
                  if run_request(Query::Destroy.new(self.class, attributes))
         
     | 
| 
      
 65 
     | 
    
         
            +
                    self.attributes.clear
         
     | 
| 
      
 66 
     | 
    
         
            +
                    true
         
     | 
| 
      
 67 
     | 
    
         
            +
                  else
         
     | 
| 
      
 68 
     | 
    
         
            +
                    false
         
     | 
| 
      
 69 
     | 
    
         
            +
                  end
         
     | 
| 
       62 
70 
     | 
    
         
             
                end
         
     | 
| 
       63 
71 
     | 
    
         | 
| 
       64 
72 
     | 
    
         
             
                protected
         
     | 
| 
       65 
73 
     | 
    
         | 
| 
       66 
74 
     | 
    
         
             
                def run_request(query)
         
     | 
| 
       67 
     | 
    
         
            -
                   
     | 
| 
       68 
     | 
    
         
            -
                  self.errors  
     | 
| 
       69 
     | 
    
         
            -
                   
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
      
 75 
     | 
    
         
            +
                  # reset errors if a new request is being made
         
     | 
| 
      
 76 
     | 
    
         
            +
                  self.errors.clear if self.errors
         
     | 
| 
      
 77 
     | 
    
         
            +
                  
         
     | 
| 
      
 78 
     | 
    
         
            +
                  result = self.class.run_request(query)
         
     | 
| 
      
 79 
     | 
    
         
            +
                  self.errors = result.errors
         
     | 
| 
      
 80 
     | 
    
         
            +
                  if result.has_errors?
         
     | 
| 
      
 81 
     | 
    
         
            +
                    return false
         
     | 
| 
       71 
82 
     | 
    
         
             
                  else
         
     | 
| 
       72 
     | 
    
         
            -
                     
     | 
| 
      
 83 
     | 
    
         
            +
                    if updated = result.first
         
     | 
| 
      
 84 
     | 
    
         
            +
                      self.attributes = updated.attributes
         
     | 
| 
      
 85 
     | 
    
         
            +
                    end
         
     | 
| 
      
 86 
     | 
    
         
            +
                    return true
         
     | 
| 
       73 
87 
     | 
    
         
             
                  end
         
     | 
| 
       74 
     | 
    
         
            -
                  return errors.length == 0
         
     | 
| 
       75 
88 
     | 
    
         
             
                end
         
     | 
| 
       76 
89 
     | 
    
         | 
| 
       77 
90 
     | 
    
         
             
              end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: json_api_client
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Jeff Ching
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-04-15 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     | 
| 
         @@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       126 
126 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       127 
127 
     | 
    
         
             
            requirements: []
         
     | 
| 
       128 
128 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       129 
     | 
    
         
            -
            rubygems_version: 2.2. 
     | 
| 
      
 129 
     | 
    
         
            +
            rubygems_version: 2.2.2
         
     | 
| 
       130 
130 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       131 
131 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       132 
132 
     | 
    
         
             
            summary: Build client libraries compliant with specification defined by jsonapi.org
         
     |