moip-assinaturas 0.4.0 → 0.4.1
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 +5 -13
- data/README.md +5 -0
- data/lib/moip-assinaturas/client.rb +5 -0
- data/lib/moip-assinaturas/customer.rb +26 -0
- data/lib/moip-assinaturas/version.rb +1 -1
- data/spec/fixtures/update_customer.json +1 -0
- data/spec/moip-assinaturas/customer_spec.rb +27 -0
- metadata +23 -21
    
        checksums.yaml
    CHANGED
    
    | @@ -1,15 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
             | 
| 5 | 
            -
              data.tar.gz: !binary |-
         | 
| 6 | 
            -
                OTYzNjY1YzczODE3ZWM5MWUzNThlMWM5NTE0ZDBmNTYxNDZiNTY1YQ==
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 5675234fd2e6fbad69922aa1fb708e3dd4a14f53
         | 
| 4 | 
            +
              data.tar.gz: 582c71bf26d906ac31117c7e437c1ca4825afb9c
         | 
| 7 5 | 
             
            SHA512:
         | 
| 8 | 
            -
              metadata.gz:  | 
| 9 | 
            -
             | 
| 10 | 
            -
                ZmU2MTg2MWUyMzc2ZDhkMmI3MGMyNDg5YWM5Y2FjYWNiMjRmYjU4MTdkNDU4
         | 
| 11 | 
            -
                ODQ4OTJhNjE0MTgzMjA3OGM1NjBkN2UxMmRmNDM2N2VhM2YxMTA=
         | 
| 12 | 
            -
              data.tar.gz: !binary |-
         | 
| 13 | 
            -
                YzNlYmRmYTNhMzllYTJiZThkZDZjZjg0OWU2MTg3NzUwYzI0NjRlOTJiODc1
         | 
| 14 | 
            -
                NGY1MGMyNDNkNjRkZGFmZjkxNTAzNWNiNDQ4ODVlNDZlNmE4NGFmZWUyNWFh
         | 
| 15 | 
            -
                MDhkMmRlYmNhMWI3MDFlOWRiODBlMzY2N2U4YmRjY2I1M2U3OGM=
         | 
| 6 | 
            +
              metadata.gz: 2f146429cef1ba2543b2962bc1c311b7422603a5fea640e10b6dd531ec07ceba7b4444f0f098143989d2882f29f8c00039bc0c432815335fb2327a3b807d008a
         | 
| 7 | 
            +
              data.tar.gz: 305c5a3845f7d85e078af1a0c42548954e42103267f1789629077b886355a0deefdbf7205622720612964076e836a428dcfe68e95510930e5f37a394da91dda9
         | 
    
        data/README.md
    CHANGED
    
    | @@ -117,6 +117,11 @@ Obter detalhes do cliente: | |
| 117 117 | 
             
            Moip::Assinaturas::Customer.details(customer_code)
         | 
| 118 118 | 
             
            ```
         | 
| 119 119 |  | 
| 120 | 
            +
            Atualizar cliente existente:
         | 
| 121 | 
            +
             | 
| 122 | 
            +
            ```ruby
         | 
| 123 | 
            +
            Moip::Assinaturas::Customer.update(customer_code, { fullname: 'Foo Bar' })
         | 
| 124 | 
            +
            ```
         | 
| 120 125 | 
             
            ## Assinaturas
         | 
| 121 126 |  | 
| 122 127 | 
             
            Criar uma nova assinatura:
         | 
| @@ -51,6 +51,11 @@ module Moip::Assinaturas | |
| 51 51 | 
             
                    peform_action!(:get, "/customers", opts)
         | 
| 52 52 | 
             
                  end
         | 
| 53 53 |  | 
| 54 | 
            +
                  def update_customer(code, changes, opts={})
         | 
| 55 | 
            +
                    prepare_options(opts, { body: changes.to_json, headers: { 'Content-Type' => 'application/json' } })
         | 
| 56 | 
            +
                    peform_action!(:put, "/customers/#{code}", opts, true)
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 54 59 | 
             
                  def details_customer(code, opts={})
         | 
| 55 60 | 
             
                    prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
         | 
| 56 61 | 
             
                    peform_action!(:get, "/customers/#{code}", opts, true)
         | 
| @@ -39,6 +39,32 @@ module Moip::Assinaturas | |
| 39 39 | 
             
                    end
         | 
| 40 40 | 
             
                  end
         | 
| 41 41 |  | 
| 42 | 
            +
                  def update(code, changes, opts = {})
         | 
| 43 | 
            +
                    response = Moip::Assinaturas::Client.update_customer(code, changes, opts)
         | 
| 44 | 
            +
                    hash     = JSON.load(response.body)
         | 
| 45 | 
            +
                    hash     = hash ? hash.with_indifferent_access : {}
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                    case response.code
         | 
| 48 | 
            +
                    when 200
         | 
| 49 | 
            +
                      return {
         | 
| 50 | 
            +
                        success: true
         | 
| 51 | 
            +
                      }
         | 
| 52 | 
            +
                    when 404
         | 
| 53 | 
            +
                      return {
         | 
| 54 | 
            +
                        success: false,
         | 
| 55 | 
            +
                        message: 'not found'
         | 
| 56 | 
            +
                      }
         | 
| 57 | 
            +
                    when 400
         | 
| 58 | 
            +
                      return {
         | 
| 59 | 
            +
                        success: false,
         | 
| 60 | 
            +
                        message: hash[:message],
         | 
| 61 | 
            +
                        errors:  hash[:errors]
         | 
| 62 | 
            +
                      }
         | 
| 63 | 
            +
                    else
         | 
| 64 | 
            +
                      raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice")
         | 
| 65 | 
            +
                    end
         | 
| 66 | 
            +
                  end
         | 
| 67 | 
            +
             | 
| 42 68 | 
             
                  def details(code, opts = {})
         | 
| 43 69 | 
             
                    response = Moip::Assinaturas::Client.details_customer(code, opts)
         | 
| 44 70 | 
             
                    hash     = JSON.load(response.body)
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            { "message": "Dados alterados com sucesso" }
         | 
| @@ -69,6 +69,20 @@ describe Moip::Assinaturas::Customer do | |
| 69 69 | 
             
                  status: [200, 'OK']
         | 
| 70 70 | 
             
                )
         | 
| 71 71 |  | 
| 72 | 
            +
                FakeWeb.register_uri(
         | 
| 73 | 
            +
                  :put,
         | 
| 74 | 
            +
                  "https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/customers/18",
         | 
| 75 | 
            +
                  body:   File.join(File.dirname(__FILE__), '..', 'fixtures', 'update_customer.json'),
         | 
| 76 | 
            +
                  status: [200, 'OK']
         | 
| 77 | 
            +
                )
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                FakeWeb.register_uri(
         | 
| 80 | 
            +
                  :put,
         | 
| 81 | 
            +
                  "https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/customers/not_found",
         | 
| 82 | 
            +
                  body: '',
         | 
| 83 | 
            +
                  status: [404, 'Not found']
         | 
| 84 | 
            +
                )
         | 
| 85 | 
            +
             | 
| 72 86 | 
             
                FakeWeb.register_uri(
         | 
| 73 87 | 
             
                  :post,
         | 
| 74 88 | 
             
                  "https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/customers?new_vault=true",
         | 
| @@ -109,6 +123,19 @@ describe Moip::Assinaturas::Customer do | |
| 109 123 | 
             
                request[:customers].size.should  == 1
         | 
| 110 124 | 
             
              end
         | 
| 111 125 |  | 
| 126 | 
            +
              describe 'update customer information' do
         | 
| 127 | 
            +
                it 'should update a customer information' do
         | 
| 128 | 
            +
                  request = Moip::Assinaturas::Customer.update(@customer[:code], { fullname: 'Foo Bar' })
         | 
| 129 | 
            +
                  request[:success].should         be_true
         | 
| 130 | 
            +
                end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                it 'should return not found when updating a customer that does not exist' do
         | 
| 133 | 
            +
                  request = Moip::Assinaturas::Customer.update('not_found', { fullname: 'Foo Bar' })
         | 
| 134 | 
            +
                  request[:success].should         be_false
         | 
| 135 | 
            +
                  request[:message].should == 'not found'
         | 
| 136 | 
            +
                end
         | 
| 137 | 
            +
              end
         | 
| 138 | 
            +
             | 
| 112 139 | 
             
              describe 'customer details' do
         | 
| 113 140 | 
             
                it "should get the customer details" do
         | 
| 114 141 | 
             
                  request = Moip::Assinaturas::Customer.details('18')
         | 
    
        metadata
    CHANGED
    
    | @@ -1,125 +1,125 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: moip-assinaturas
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.4. | 
| 4 | 
            +
              version: 0.4.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Warlley
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-08- | 
| 11 | 
            +
            date: 2014-08-25 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rspec
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 | 
            -
                - - ~>
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 19 | 
             
                    version: '2.13'
         | 
| 20 20 | 
             
              type: :development
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 | 
            -
                - - ~>
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 26 | 
             
                    version: '2.13'
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: guard-rspec
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 30 | 
             
                requirements:
         | 
| 31 | 
            -
                - - ~>
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 33 | 
             
                    version: 2.5.4
         | 
| 34 34 | 
             
              type: :development
         | 
| 35 35 | 
             
              prerelease: false
         | 
| 36 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 37 | 
             
                requirements:
         | 
| 38 | 
            -
                - - ~>
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 40 | 
             
                    version: 2.5.4
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 42 | 
             
              name: growl
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 44 | 
             
                requirements:
         | 
| 45 | 
            -
                - - ~>
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 47 | 
             
                    version: 1.0.3
         | 
| 48 48 | 
             
              type: :development
         | 
| 49 49 | 
             
              prerelease: false
         | 
| 50 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 51 | 
             
                requirements:
         | 
| 52 | 
            -
                - - ~>
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 54 | 
             
                    version: 1.0.3
         | 
| 55 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 56 | 
             
              name: fakeweb
         | 
| 57 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 58 | 
             
                requirements:
         | 
| 59 | 
            -
                - - ~>
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 61 | 
             
                    version: 1.3.0
         | 
| 62 62 | 
             
              type: :development
         | 
| 63 63 | 
             
              prerelease: false
         | 
| 64 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 65 | 
             
                requirements:
         | 
| 66 | 
            -
                - - ~>
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 68 | 
             
                    version: 1.3.0
         | 
| 69 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 70 | 
             
              name: pry
         | 
| 71 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 72 | 
             
                requirements:
         | 
| 73 | 
            -
                - - ~>
         | 
| 73 | 
            +
                - - "~>"
         | 
| 74 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 75 | 
             
                    version: '0.9'
         | 
| 76 76 | 
             
              type: :development
         | 
| 77 77 | 
             
              prerelease: false
         | 
| 78 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 79 | 
             
                requirements:
         | 
| 80 | 
            -
                - - ~>
         | 
| 80 | 
            +
                - - "~>"
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 82 | 
             
                    version: '0.9'
         | 
| 83 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 84 | 
             
              name: httparty
         | 
| 85 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 86 | 
             
                requirements:
         | 
| 87 | 
            -
                - - ~>
         | 
| 87 | 
            +
                - - "~>"
         | 
| 88 88 | 
             
                  - !ruby/object:Gem::Version
         | 
| 89 89 | 
             
                    version: 0.12.0
         | 
| 90 90 | 
             
              type: :runtime
         | 
| 91 91 | 
             
              prerelease: false
         | 
| 92 92 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 93 | 
             
                requirements:
         | 
| 94 | 
            -
                - - ~>
         | 
| 94 | 
            +
                - - "~>"
         | 
| 95 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 96 96 | 
             
                    version: 0.12.0
         | 
| 97 97 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 98 98 | 
             
              name: activesupport
         | 
| 99 99 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 100 | 
             
                requirements:
         | 
| 101 | 
            -
                - -  | 
| 101 | 
            +
                - - ">="
         | 
| 102 102 | 
             
                  - !ruby/object:Gem::Version
         | 
| 103 103 | 
             
                    version: 2.3.2
         | 
| 104 104 | 
             
              type: :runtime
         | 
| 105 105 | 
             
              prerelease: false
         | 
| 106 106 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 107 | 
             
                requirements:
         | 
| 108 | 
            -
                - -  | 
| 108 | 
            +
                - - ">="
         | 
| 109 109 | 
             
                  - !ruby/object:Gem::Version
         | 
| 110 110 | 
             
                    version: 2.3.2
         | 
| 111 111 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 112 112 | 
             
              name: json
         | 
| 113 113 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 114 | 
             
                requirements:
         | 
| 115 | 
            -
                - -  | 
| 115 | 
            +
                - - ">="
         | 
| 116 116 | 
             
                  - !ruby/object:Gem::Version
         | 
| 117 117 | 
             
                    version: '1.7'
         | 
| 118 118 | 
             
              type: :runtime
         | 
| 119 119 | 
             
              prerelease: false
         | 
| 120 120 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 121 | 
             
                requirements:
         | 
| 122 | 
            -
                - -  | 
| 122 | 
            +
                - - ">="
         | 
| 123 123 | 
             
                  - !ruby/object:Gem::Version
         | 
| 124 124 | 
             
                    version: '1.7'
         | 
| 125 125 | 
             
            description: Ruby Gem para uso do serviço de assinaturas do Moip
         | 
| @@ -129,7 +129,7 @@ executables: [] | |
| 129 129 | 
             
            extensions: []
         | 
| 130 130 | 
             
            extra_rdoc_files: []
         | 
| 131 131 | 
             
            files:
         | 
| 132 | 
            -
            - .gitignore
         | 
| 132 | 
            +
            - ".gitignore"
         | 
| 133 133 | 
             
            - Gemfile
         | 
| 134 134 | 
             
            - Guardfile
         | 
| 135 135 | 
             
            - LICENSE.txt
         | 
| @@ -175,6 +175,7 @@ files: | |
| 175 175 | 
             
            - spec/fixtures/list_plans.json
         | 
| 176 176 | 
             
            - spec/fixtures/list_subscriptions.json
         | 
| 177 177 | 
             
            - spec/fixtures/update_credit_card.json
         | 
| 178 | 
            +
            - spec/fixtures/update_customer.json
         | 
| 178 179 | 
             
            - spec/moip-assinaturas/customer_spec.rb
         | 
| 179 180 | 
             
            - spec/moip-assinaturas/invoice_spec.rb
         | 
| 180 181 | 
             
            - spec/moip-assinaturas/payment_spec.rb
         | 
| @@ -192,12 +193,12 @@ require_paths: | |
| 192 193 | 
             
            - lib
         | 
| 193 194 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 194 195 | 
             
              requirements:
         | 
| 195 | 
            -
              - -  | 
| 196 | 
            +
              - - ">="
         | 
| 196 197 | 
             
                - !ruby/object:Gem::Version
         | 
| 197 198 | 
             
                  version: '0'
         | 
| 198 199 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 199 200 | 
             
              requirements:
         | 
| 200 | 
            -
              - -  | 
| 201 | 
            +
              - - ">="
         | 
| 201 202 | 
             
                - !ruby/object:Gem::Version
         | 
| 202 203 | 
             
                  version: '0'
         | 
| 203 204 | 
             
            requirements: []
         | 
| @@ -235,6 +236,7 @@ test_files: | |
| 235 236 | 
             
            - spec/fixtures/list_plans.json
         | 
| 236 237 | 
             
            - spec/fixtures/list_subscriptions.json
         | 
| 237 238 | 
             
            - spec/fixtures/update_credit_card.json
         | 
| 239 | 
            +
            - spec/fixtures/update_customer.json
         | 
| 238 240 | 
             
            - spec/moip-assinaturas/customer_spec.rb
         | 
| 239 241 | 
             
            - spec/moip-assinaturas/invoice_spec.rb
         | 
| 240 242 | 
             
            - spec/moip-assinaturas/payment_spec.rb
         |