pwinty 1.1.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 +5 -5
 - data/.gitignore +12 -5
 - data/.rspec +3 -0
 - data/.travis.yml +22 -4
 - data/CODE_OF_CONDUCT.md +74 -0
 - data/Gemfile +4 -2
 - data/Gemfile.lock +97 -0
 - data/LICENSE.txt +21 -0
 - data/README.md +208 -60
 - data/Rakefile +3 -8
 - data/bin/console +14 -0
 - data/bin/setup +8 -0
 - data/lib/pwinty.rb +47 -73
 - data/lib/pwinty/base.rb +12 -0
 - data/lib/pwinty/country.rb +12 -0
 - data/lib/pwinty/http_errors.rb +13 -0
 - data/lib/pwinty/image.rb +24 -0
 - data/lib/pwinty/order.rb +110 -0
 - data/lib/pwinty/order_status.rb +17 -0
 - data/lib/pwinty/photo_status.rb +8 -0
 - data/lib/pwinty/shipment.rb +14 -0
 - data/lib/pwinty/shipping_info.rb +9 -0
 - data/lib/pwinty/version.rb +1 -1
 - data/pwinty.gemspec +34 -19
 - metadata +141 -35
 - data/CHANGELOG.md +0 -10
 - data/CONTRIBUTING.md +0 -18
 - data/lib/multipart.rb +0 -76
 - data/test/test_client.rb +0 -117
 - data/test/test_helper.rb +0 -5
 
    
        metadata
    CHANGED
    
    | 
         @@ -1,92 +1,201 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: pwinty
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version:  
     | 
| 
      
 4 
     | 
    
         
            +
              version: 3.0.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
     | 
    
         
            -
            -  
     | 
| 
      
 7 
     | 
    
         
            +
            - Thomas Harvey
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
     | 
    
         
            -
            bindir:  
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-08-27 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '1.17'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '1.17'
         
     | 
| 
       13 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
28 
     | 
    
         
             
              name: rake
         
     | 
| 
       15 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
     | 
    
         
            -
                - - " 
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       18 
46 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '3.0'
         
     | 
| 
       20 
48 
     | 
    
         
             
              type: :development
         
     | 
| 
       21 
49 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
50 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
51 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
     | 
    
         
            -
                - - " 
     | 
| 
      
 52 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       25 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '3.0'
         
     | 
| 
       27 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
     | 
    
         
            -
              name:  
     | 
| 
      
 56 
     | 
    
         
            +
              name: vcr
         
     | 
| 
       29 
57 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
58 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
     | 
    
         
            -
                - - " 
     | 
| 
      
 59 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       32 
60 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '5.0'
         
     | 
| 
       34 
62 
     | 
    
         
             
              type: :development
         
     | 
| 
       35 
63 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
64 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
65 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
     | 
    
         
            -
                - - " 
     | 
| 
      
 66 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       39 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: '5.0'
         
     | 
| 
       41 
69 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
     | 
    
         
            -
              name:  
     | 
| 
      
 70 
     | 
    
         
            +
              name: webmock
         
     | 
| 
       43 
71 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       44 
72 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
     | 
    
         
            -
                - - " 
     | 
| 
      
 73 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       46 
74 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       47 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 75 
     | 
    
         
            +
                    version: '3.6'
         
     | 
| 
       48 
76 
     | 
    
         
             
              type: :development
         
     | 
| 
       49 
77 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       50 
78 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       51 
79 
     | 
    
         
             
                requirements:
         
     | 
| 
       52 
     | 
    
         
            -
                - - " 
     | 
| 
      
 80 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 81 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 82 
     | 
    
         
            +
                    version: '3.6'
         
     | 
| 
      
 83 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 84 
     | 
    
         
            +
              name: simplecov
         
     | 
| 
      
 85 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 86 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 87 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 88 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 89 
     | 
    
         
            +
                    version: '0.17'
         
     | 
| 
      
 90 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 91 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 92 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 93 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 94 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 95 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 96 
     | 
    
         
            +
                    version: '0.17'
         
     | 
| 
      
 97 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 98 
     | 
    
         
            +
              name: dry-struct
         
     | 
| 
      
 99 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 100 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 101 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 102 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 103 
     | 
    
         
            +
                    version: '1.0'
         
     | 
| 
      
 104 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 105 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 106 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 107 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 108 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 109 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 110 
     | 
    
         
            +
                    version: '1.0'
         
     | 
| 
      
 111 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 112 
     | 
    
         
            +
              name: dry-struct-setters
         
     | 
| 
      
 113 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 114 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 115 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 116 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 117 
     | 
    
         
            +
                    version: '0.2'
         
     | 
| 
      
 118 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 119 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 120 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 121 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 122 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 123 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 124 
     | 
    
         
            +
                    version: '0.2'
         
     | 
| 
      
 125 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 126 
     | 
    
         
            +
              name: faraday
         
     | 
| 
      
 127 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 128 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 129 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 130 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 131 
     | 
    
         
            +
                    version: '0.15'
         
     | 
| 
      
 132 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 133 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 134 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 135 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 136 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 137 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 138 
     | 
    
         
            +
                    version: '0.15'
         
     | 
| 
      
 139 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 140 
     | 
    
         
            +
              name: faraday_middleware
         
     | 
| 
      
 141 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 142 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 143 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 144 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 145 
     | 
    
         
            +
                    version: '0.13'
         
     | 
| 
      
 146 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 147 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 148 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 149 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 150 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       53 
151 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
      
 152 
     | 
    
         
            +
                    version: '0.13'
         
     | 
| 
       55 
153 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
     | 
    
         
            -
              name:  
     | 
| 
      
 154 
     | 
    
         
            +
              name: json
         
     | 
| 
       57 
155 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       58 
156 
     | 
    
         
             
                requirements:
         
     | 
| 
       59 
157 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       60 
158 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       61 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 159 
     | 
    
         
            +
                    version: '2.2'
         
     | 
| 
       62 
160 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       63 
161 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       64 
162 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       65 
163 
     | 
    
         
             
                requirements:
         
     | 
| 
       66 
164 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       67 
165 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       68 
     | 
    
         
            -
                    version: ' 
     | 
| 
       69 
     | 
    
         
            -
            description:  
     | 
| 
      
 166 
     | 
    
         
            +
                    version: '2.2'
         
     | 
| 
      
 167 
     | 
    
         
            +
            description: This wraps the Pwinty API at version 3 and aims to make your ruby life
         
     | 
| 
      
 168 
     | 
    
         
            +
              easier when interacting with the API.
         
     | 
| 
       70 
169 
     | 
    
         
             
            email:
         
     | 
| 
       71 
     | 
    
         
            -
            -  
     | 
| 
      
 170 
     | 
    
         
            +
            - tom@alush.co.uk
         
     | 
| 
       72 
171 
     | 
    
         
             
            executables: []
         
     | 
| 
       73 
172 
     | 
    
         
             
            extensions: []
         
     | 
| 
       74 
173 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       75 
174 
     | 
    
         
             
            files:
         
     | 
| 
       76 
175 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
      
 176 
     | 
    
         
            +
            - ".rspec"
         
     | 
| 
       77 
177 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
       78 
     | 
    
         
            -
            -  
     | 
| 
       79 
     | 
    
         
            -
            - CONTRIBUTING.md
         
     | 
| 
      
 178 
     | 
    
         
            +
            - CODE_OF_CONDUCT.md
         
     | 
| 
       80 
179 
     | 
    
         
             
            - Gemfile
         
     | 
| 
      
 180 
     | 
    
         
            +
            - Gemfile.lock
         
     | 
| 
      
 181 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
       81 
182 
     | 
    
         
             
            - README.md
         
     | 
| 
       82 
183 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       83 
     | 
    
         
            -
            -  
     | 
| 
      
 184 
     | 
    
         
            +
            - bin/console
         
     | 
| 
      
 185 
     | 
    
         
            +
            - bin/setup
         
     | 
| 
       84 
186 
     | 
    
         
             
            - lib/pwinty.rb
         
     | 
| 
      
 187 
     | 
    
         
            +
            - lib/pwinty/base.rb
         
     | 
| 
      
 188 
     | 
    
         
            +
            - lib/pwinty/country.rb
         
     | 
| 
      
 189 
     | 
    
         
            +
            - lib/pwinty/http_errors.rb
         
     | 
| 
      
 190 
     | 
    
         
            +
            - lib/pwinty/image.rb
         
     | 
| 
      
 191 
     | 
    
         
            +
            - lib/pwinty/order.rb
         
     | 
| 
      
 192 
     | 
    
         
            +
            - lib/pwinty/order_status.rb
         
     | 
| 
      
 193 
     | 
    
         
            +
            - lib/pwinty/photo_status.rb
         
     | 
| 
      
 194 
     | 
    
         
            +
            - lib/pwinty/shipment.rb
         
     | 
| 
      
 195 
     | 
    
         
            +
            - lib/pwinty/shipping_info.rb
         
     | 
| 
       85 
196 
     | 
    
         
             
            - lib/pwinty/version.rb
         
     | 
| 
       86 
197 
     | 
    
         
             
            - pwinty.gemspec
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
            - test/test_helper.rb
         
     | 
| 
       89 
     | 
    
         
            -
            homepage: http://github.com/dereklucas/pwinty
         
     | 
| 
      
 198 
     | 
    
         
            +
            homepage: https://github.com/tomharvey/pwinty3-rb
         
     | 
| 
       90 
199 
     | 
    
         
             
            licenses:
         
     | 
| 
       91 
200 
     | 
    
         
             
            - MIT
         
     | 
| 
       92 
201 
     | 
    
         
             
            metadata: {}
         
     | 
| 
         @@ -106,11 +215,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       106 
215 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       107 
216 
     | 
    
         
             
            requirements: []
         
     | 
| 
       108 
217 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       109 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 218 
     | 
    
         
            +
            rubygems_version: 2.7.7
         
     | 
| 
       110 
219 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       111 
220 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       112 
     | 
    
         
            -
            summary:  
     | 
| 
       113 
     | 
    
         
            -
            test_files:
         
     | 
| 
       114 
     | 
    
         
            -
            - test/test_client.rb
         
     | 
| 
       115 
     | 
    
         
            -
            - test/test_helper.rb
         
     | 
| 
       116 
     | 
    
         
            -
            has_rdoc: 
         
     | 
| 
      
 221 
     | 
    
         
            +
            summary: Order photo prints through Pwinty
         
     | 
| 
      
 222 
     | 
    
         
            +
            test_files: []
         
     | 
    
        data/CHANGELOG.md
    DELETED
    
    | 
         @@ -1,10 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            ## 1.1.0 (2016-12-26)
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            * Add support for adding photos in a batch (Thanks @bumi!)
         
     | 
| 
       4 
     | 
    
         
            -
            * Support for configurable Pwinty API versions (Thanks @bumi!)
         
     | 
| 
       5 
     | 
    
         
            -
            * Added support for passing client credentials as arguments instead of ENV variables (Thanks @bumi!)
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            ## 1.0.1 (2015-04-10)
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            * Create a working Pwinty client with [rest-client](https://github.com/rest-client/rest-client)
         
     | 
    
        data/CONTRIBUTING.md
    DELETED
    
    | 
         @@ -1,18 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            ## Getting Involved
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another.
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            ### Coding
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            * Pick a task:
         
     | 
| 
       8 
     | 
    
         
            -
              * Offer feedback on open [pull requests](https://github.com/dereklucas/pwinty/pulls).
         
     | 
| 
       9 
     | 
    
         
            -
              * Review open [issues](https://github.com/dereklucas/pwinty/issues) for things to help on.
         
     | 
| 
       10 
     | 
    
         
            -
              * [Create an issue](https://github.com/dereklucas/pwinty/issues/new) to start a discussion on additions or features.
         
     | 
| 
       11 
     | 
    
         
            -
            * Fork the project, add your changes and tests to cover them in a topic branch.
         
     | 
| 
       12 
     | 
    
         
            -
            * Commit your changes and rebase against `dereklucas/pwinty` to ensure everything is up to date.
         
     | 
| 
       13 
     | 
    
         
            -
            * [Submit a pull request](https://github.com/dereklucas/pwinty/compare/)
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            ### Non-Coding
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            * Offer feedback on open [issues](https://github.com/dereklucas/pwinty/issues).
         
     | 
| 
       18 
     | 
    
         
            -
            * Organize or volunteer at events.
         
     | 
    
        data/lib/multipart.rb
    DELETED
    
    | 
         @@ -1,76 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # License:: Distributed under the terms of the WTFPL (http://www.wtfpl.net/txt/copying/)
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'mime/types'
         
     | 
| 
       5 
     | 
    
         
            -
            require 'cgi'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            module Multipart
         
     | 
| 
       9 
     | 
    
         
            -
              VERSION = "1.0.0"
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              # Formats a given hash as a multipart form post
         
     | 
| 
       12 
     | 
    
         
            -
              # If a hash value responds to :string or :read messages, then it is
         
     | 
| 
       13 
     | 
    
         
            -
              # interpreted as a file and processed accordingly; otherwise, it is assumed
         
     | 
| 
       14 
     | 
    
         
            -
              # to be a string
         
     | 
| 
       15 
     | 
    
         
            -
              class Post
         
     | 
| 
       16 
     | 
    
         
            -
                # We have to pretend we're a web browser...
         
     | 
| 
       17 
     | 
    
         
            -
                USERAGENT = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/523.10.6 (KHTML, like Gecko) Version/3.0.4 Safari/523.10.6"
         
     | 
| 
       18 
     | 
    
         
            -
                BOUNDARY = "0123456789ABLEWASIEREISAWELBA9876543210"
         
     | 
| 
       19 
     | 
    
         
            -
                CONTENT_TYPE = "multipart/form-data; boundary=#{ BOUNDARY }"
         
     | 
| 
       20 
     | 
    
         
            -
                HEADER = { "Content-Type" => CONTENT_TYPE, "User-Agent" => USERAGENT }
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                def self.prepare_query(params)
         
     | 
| 
       23 
     | 
    
         
            -
                  fp = []
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                  params.each do |k, v|
         
     | 
| 
       26 
     | 
    
         
            -
                    # Are we trying to make a file parameter?
         
     | 
| 
       27 
     | 
    
         
            -
                    if v.respond_to?(:path) and v.respond_to?(:read) then
         
     | 
| 
       28 
     | 
    
         
            -
                      fp.push(FileParam.new(k.to_s, v.path, v.read))
         
     | 
| 
       29 
     | 
    
         
            -
                    # We must be trying to make a regular parameter
         
     | 
| 
       30 
     | 
    
         
            -
                    else
         
     | 
| 
       31 
     | 
    
         
            -
                      fp.push(StringParam.new(k.to_s, v))
         
     | 
| 
       32 
     | 
    
         
            -
                    end
         
     | 
| 
       33 
     | 
    
         
            -
                  end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                  # Assemble the request body using the special multipart format
         
     | 
| 
       36 
     | 
    
         
            -
                  query = fp.collect {|p| "--" + BOUNDARY + "\r\n" + p.to_multipart }.join("") + "--" + BOUNDARY + "--"
         
     | 
| 
       37 
     | 
    
         
            -
                  return query, HEADER
         
     | 
| 
       38 
     | 
    
         
            -
                end
         
     | 
| 
       39 
     | 
    
         
            -
              end
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
              private
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
              # Formats a basic string key/value pair for inclusion with a multipart post
         
     | 
| 
       44 
     | 
    
         
            -
              class StringParam
         
     | 
| 
       45 
     | 
    
         
            -
                attr_accessor :k, :v
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                def initialize(k, v)
         
     | 
| 
       48 
     | 
    
         
            -
                  @k = k
         
     | 
| 
       49 
     | 
    
         
            -
                  @v = v
         
     | 
| 
       50 
     | 
    
         
            -
                end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                def to_multipart
         
     | 
| 
       53 
     | 
    
         
            -
                  return "Content-Disposition: form-data; name=\"#{CGI::escape(k)}\"\r\n\r\n#{v}\r\n"
         
     | 
| 
       54 
     | 
    
         
            -
                end
         
     | 
| 
       55 
     | 
    
         
            -
              end
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
              # Formats the contents of a file or string for inclusion with a multipart
         
     | 
| 
       58 
     | 
    
         
            -
              # form post
         
     | 
| 
       59 
     | 
    
         
            -
              class FileParam
         
     | 
| 
       60 
     | 
    
         
            -
                attr_accessor :k, :filename, :content
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                def initialize(k, filename, content)
         
     | 
| 
       63 
     | 
    
         
            -
                  @k = k
         
     | 
| 
       64 
     | 
    
         
            -
                  @filename = filename
         
     | 
| 
       65 
     | 
    
         
            -
                  @content = content
         
     | 
| 
       66 
     | 
    
         
            -
                end
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                def to_multipart
         
     | 
| 
       69 
     | 
    
         
            -
                  # If we can tell the possible mime-type from the filename, use the
         
     | 
| 
       70 
     | 
    
         
            -
                  # first in the list; otherwise, use "application/octet-stream"
         
     | 
| 
       71 
     | 
    
         
            -
                  mime_type = MIME::Types.type_for(filename)[0] || MIME::Types["application/octet-stream"][0]
         
     | 
| 
       72 
     | 
    
         
            -
                  return "Content-Disposition: form-data; name=\"#{CGI::escape(k)}\"; filename=\"#{ filename }\"\r\n" +
         
     | 
| 
       73 
     | 
    
         
            -
                         "Content-Type: #{ mime_type.simplified }\r\n\r\n#{ content }\r\n"
         
     | 
| 
       74 
     | 
    
         
            -
                end
         
     | 
| 
       75 
     | 
    
         
            -
              end
         
     | 
| 
       76 
     | 
    
         
            -
            end
         
     | 
    
        data/test/test_client.rb
    DELETED
    
    | 
         @@ -1,117 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "test_helper"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class TestClient < Test::Unit::TestCase
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              def setup
         
     | 
| 
       6 
     | 
    
         
            -
                @params = {
         
     | 
| 
       7 
     | 
    
         
            -
                  recipientName: "FirstName LastName",
         
     | 
| 
       8 
     | 
    
         
            -
                  address1: "123 Anywhere Street",
         
     | 
| 
       9 
     | 
    
         
            -
                  addressTownOrCity: "San Francisco",
         
     | 
| 
       10 
     | 
    
         
            -
                  stateOrCounty: "CA",
         
     | 
| 
       11 
     | 
    
         
            -
                  postalOrZipCode: "94101",
         
     | 
| 
       12 
     | 
    
         
            -
                  countryCode: "US",
         
     | 
| 
       13 
     | 
    
         
            -
                  payment: "InvoiceMe",
         
     | 
| 
       14 
     | 
    
         
            -
                  qualityLevel: "Standard"
         
     | 
| 
       15 
     | 
    
         
            -
                }
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                @client = Pwinty.client(merchant_id: ENV['PWINTY_MERCHANT_ID'], api_key: ENV['PWINTY_API_KEY'], production: false)
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                @order_keys = %w[ id status price
         
     | 
| 
       20 
     | 
    
         
            -
                                  address1 address2
         
     | 
| 
       21 
     | 
    
         
            -
                                  addressTownOrCity
         
     | 
| 
       22 
     | 
    
         
            -
                                  countryCode
         
     | 
| 
       23 
     | 
    
         
            -
                                  destinationCountryCode
         
     | 
| 
       24 
     | 
    
         
            -
                                  errorMessage qualityLevel
         
     | 
| 
       25 
     | 
    
         
            -
                                  payment paymentUrl
         
     | 
| 
       26 
     | 
    
         
            -
                                  photos postalOrZipCode
         
     | 
| 
       27 
     | 
    
         
            -
                                  recipientName shippingInfo
         
     | 
| 
       28 
     | 
    
         
            -
                                  stateOrCounty ]
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
              def test_initialize
         
     | 
| 
       32 
     | 
    
         
            -
                body = @client.catalog
         
     | 
| 
       33 
     | 
    
         
            -
                assert_equal body.class, Hash
         
     | 
| 
       34 
     | 
    
         
            -
              end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
              def test_catalog_integration
         
     | 
| 
       37 
     | 
    
         
            -
                body = @client.catalog
         
     | 
| 
       38 
     | 
    
         
            -
                assert_equal body.class, Hash
         
     | 
| 
       39 
     | 
    
         
            -
                assert_equal body["countryCode"], "US"
         
     | 
| 
       40 
     | 
    
         
            -
                assert_equal body["qualityLevel"], "Standard"
         
     | 
| 
       41 
     | 
    
         
            -
                assert_equal body["shippingRates"].class, Array
         
     | 
| 
       42 
     | 
    
         
            -
                assert_equal body["items"].class, Array
         
     | 
| 
       43 
     | 
    
         
            -
              end
         
     | 
| 
       44 
     | 
    
         
            -
              def test_get_orders_integration
         
     | 
| 
       45 
     | 
    
         
            -
                # NOTE: works only if you already have an order created. the first ever test run will probably fail
         
     | 
| 
       46 
     | 
    
         
            -
                body = @client.get_orders
         
     | 
| 
       47 
     | 
    
         
            -
                assert_equal body.class, Array
         
     | 
| 
       48 
     | 
    
         
            -
                assert_equal body.first.keys.sort!, @order_keys.sort!
         
     | 
| 
       49 
     | 
    
         
            -
              end
         
     | 
| 
       50 
     | 
    
         
            -
              def test_countries_integration
         
     | 
| 
       51 
     | 
    
         
            -
                body = @client.countries
         
     | 
| 
       52 
     | 
    
         
            -
                keys = %w[ countryCode name
         
     | 
| 
       53 
     | 
    
         
            -
                           hasProducts errorMessage ]
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                assert_equal body.class, Array
         
     | 
| 
       56 
     | 
    
         
            -
                assert_equal body.first.keys.sort!, keys.sort!
         
     | 
| 
       57 
     | 
    
         
            -
              end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
              def test_orders_integration
         
     | 
| 
       60 
     | 
    
         
            -
                # create Order
         
     | 
| 
       61 
     | 
    
         
            -
                body = @client.create_order(@params)
         
     | 
| 
       62 
     | 
    
         
            -
                assert_equal body.keys.sort!, @order_keys.sort!
         
     | 
| 
       63 
     | 
    
         
            -
                assert_equal body["postalOrZipCode"], "94101"
         
     | 
| 
       64 
     | 
    
         
            -
                id = body["id"]
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                body = @client.update_order(id: id, recipientName: 'Travis CI', postalOrZipCode: '94102')
         
     | 
| 
       68 
     | 
    
         
            -
                assert_equal body.keys.sort!, @order_keys.sort!
         
     | 
| 
       69 
     | 
    
         
            -
                assert_equal body["postalOrZipCode"], "94102"
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
                # add Photo to Order via URL
         
     | 
| 
       72 
     | 
    
         
            -
                body = @client.add_photo(orderId: id,
         
     | 
| 
       73 
     | 
    
         
            -
                                         type: "4x6",
         
     | 
| 
       74 
     | 
    
         
            -
                                         url: "http://i.imgur.com/xXnrL.jpg",
         
     | 
| 
       75 
     | 
    
         
            -
                                         copies: 1, sizing: "Crop")
         
     | 
| 
       76 
     | 
    
         
            -
                photo_id = body['id']
         
     | 
| 
       77 
     | 
    
         
            -
                first_photo = body
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
                keys = %w[ id type url
         
     | 
| 
       80 
     | 
    
         
            -
                           status copies
         
     | 
| 
       81 
     | 
    
         
            -
                           sizing priceToUser
         
     | 
| 
       82 
     | 
    
         
            -
                           price md5Hash previewUrl
         
     | 
| 
       83 
     | 
    
         
            -
                           thumbnailUrl attributes
         
     | 
| 
       84 
     | 
    
         
            -
                           errorMessage ]
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
                assert_equal body.keys.sort!, keys.sort!
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
                # Check photo was uploaded
         
     | 
| 
       89 
     | 
    
         
            -
                body = @client.get_photos(id)
         
     | 
| 
       90 
     | 
    
         
            -
                assert_equal body.length, 1
         
     | 
| 
       91 
     | 
    
         
            -
                assert_equal body.first, first_photo
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
                # Check photo was uploaded
         
     | 
| 
       94 
     | 
    
         
            -
                body = @client.get_photo(id, photo_id)
         
     | 
| 
       95 
     | 
    
         
            -
                assert_equal body, first_photo
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
                # Delete photo
         
     | 
| 
       98 
     | 
    
         
            -
                body = @client.delete_photo(id, photo_id)
         
     | 
| 
       99 
     | 
    
         
            -
                assert_equal body['errorMessage'], nil
         
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
                # TODO: Need to add a photo via file
         
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
                # get Order Status
         
     | 
| 
       104 
     | 
    
         
            -
                body = @client.get_order_status(id)
         
     | 
| 
       105 
     | 
    
         
            -
                keys = %w[id isValid generalErrors photos]
         
     | 
| 
       106 
     | 
    
         
            -
                if body["error"]
         
     | 
| 
       107 
     | 
    
         
            -
                  assert body["error"].class, String
         
     | 
| 
       108 
     | 
    
         
            -
                else
         
     | 
| 
       109 
     | 
    
         
            -
                  assert_equal body.keys.sort!, keys.sort!
         
     | 
| 
       110 
     | 
    
         
            -
                end
         
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
                # Cancel Order
         
     | 
| 
       113 
     | 
    
         
            -
                body = @client.update_order_status(id, "Cancelled")
         
     | 
| 
       114 
     | 
    
         
            -
                assert_equal body['errorMessage'], nil
         
     | 
| 
       115 
     | 
    
         
            -
              end
         
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
            end
         
     |